If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Substituting my own MsgBox for the standard delete confirm MsgBox
I have a form with some code that allows the user to hit a command button
that deletes the current record. Access routinely asks the user to confirm that they wish to delete the record. My questions...can I substitute the standard Access message with my own? How would I do this? It's not an "error" so I wouldn't think writing my own error handler would do the trick. John |
#2
|
|||
|
|||
You can use a standard message box, but with your own button configuration,
or a custom form built like a message box which can also allow you to use a custom function with the "message box". First, there are 2 ways that you can achieve usage of the message box, the statement, and the function. Examples: Statement: MsgBox "Hello World!", vbOKOnly, "Test Example" Function(Example from Access 97 Help): Dim Msg, Style, Title, Help, Ctxt, Response, MyString Msg = "Do you want to continue ?" ' Define message. Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons. Title = "MsgBox Demonstration" ' Define title. Help = "DEMO.HLP" ' Define Help file. Ctxt = 1000 ' Define topic ' context. ' Display message. Response = MsgBox(Msg, Style, Title, Help, Ctxt) If Response = vbYes Then ' User chose Yes. MyString = "Yes" ' Perform some action. Else ' User chose No. MyString = "No" ' Perform some action. End If A custom MsgBox is available on my website, convertable to any version of Access: http://www.datastrat.com/Download/MsgBox2K.zip -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "John S. Ford, MD" wrote in message ... I have a form with some code that allows the user to hit a command button that deletes the current record. Access routinely asks the user to confirm that they wish to delete the record. My questions...can I substitute the standard Access message with my own? How would I do this? It's not an "error" so I wouldn't think writing my own error handler would do the trick. John |
#3
|
|||
|
|||
I think John's question is more "How can I intercept the event that prompts
the user whether they want to delete?" I'm not sure you can intercept that prompt, but you can turn it off using DoCmd.SetWarnings False, or you can use the Execute method to run SQL to do the delete. If you're turning off the warnings, make sure to turn them back on when you're done. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (No private e-mails, please) "Arvin Meyer" wrote in message ... You can use a standard message box, but with your own button configuration, or a custom form built like a message box which can also allow you to use a custom function with the "message box". First, there are 2 ways that you can achieve usage of the message box, the statement, and the function. Examples: Statement: MsgBox "Hello World!", vbOKOnly, "Test Example" Function(Example from Access 97 Help): Dim Msg, Style, Title, Help, Ctxt, Response, MyString Msg = "Do you want to continue ?" ' Define message. Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons. Title = "MsgBox Demonstration" ' Define title. Help = "DEMO.HLP" ' Define Help file. Ctxt = 1000 ' Define topic ' context. ' Display message. Response = MsgBox(Msg, Style, Title, Help, Ctxt) If Response = vbYes Then ' User chose Yes. MyString = "Yes" ' Perform some action. Else ' User chose No. MyString = "No" ' Perform some action. End If A custom MsgBox is available on my website, convertable to any version of Access: http://www.datastrat.com/Download/MsgBox2K.zip -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "John S. Ford, MD" wrote in message ... I have a form with some code that allows the user to hit a command button that deletes the current record. Access routinely asks the user to confirm that they wish to delete the record. My questions...can I substitute the standard Access message with my own? How would I do this? It's not an "error" so I wouldn't think writing my own error handler would do the trick. John |
#4
|
|||
|
|||
Right Doug,
I know I can turn the warning off. I was trying to substitute my own warning. Some users won't even know what a "record" is. They will know what a "Patient" is though and I'd like the warning to reflect that. John |
#5
|
|||
|
|||
So turn the warning off, and display your own message box before you
actually do the delete. I've built applications where I've taken it further than that. To ensure RI, I've written my own queries to determine whether I can delete records because of existing child records (or whether there are child records that will be cascade deleted) and told the users that in my message box before I've even attempted to do the delete. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (No private e-mails, please) "John S. Ford, MD" wrote in message ... Right Doug, I know I can turn the warning off. I was trying to substitute my own warning. Some users won't even know what a "record" is. They will know what a "Patient" is though and I'd like the warning to reflect that. John |
#6
|
|||
|
|||
Code your CommandButton_Click Event to show your own MsgBox. Use the result
of the MsgBox to proceed with the deletion or not. Something ****Untested**** Private Sub Command_Click() Dim intResponse As Integer intResponse = MsgBox("Delete Patient?", vbYesNo + _ vbDefaultButton2 + vbQuestion, "Confirm Deletion?") If intResponse = vbYes Then DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings False End If End Sub ******** -- HTH Van T. Dinh MVP (Access) "John S. Ford, MD" wrote in message ... Right Doug, I know I can turn the warning off. I was trying to substitute my own warning. Some users won't even know what a "record" is. They will know what a "Patient" is though and I'd like the warning to reflect that. John |
#7
|
|||
|
|||
You may want to take a look at the BeforeDelConfirm event which can be
cancelled should you decide not to delete the record. If it is cancelled, the warning message won't appear. If not, you can SetWarnings False and proceed with the deletion. I never allow most users to delete records, so I haven't spent much time working with these events. My preference is to mark records to not be displayed, then requery the recordsource so that the "deleted" record is no longer seen. It's more trouble in the beginning, but far less than having a clueless user (or worse, a malicious user) run amok in the database. BTW, I see the word "Patient" and notice that you are an MD, so I am assuming that you are building a medical database. Access security must be strictly adhered to to achieve compliance with HIPPA laws. It is important, that you spend adequate time teaching your users what a "record" is and the nuances of patient privacy, as well as protection of the personal financial information. When you are nearing completion of your project, be sure to get a security audit to make sure you and your patients are protected. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access Downloads http://www.datastrat.com http://www.mvps.org/access "John S. Ford, MD" wrote in message ... Right Doug, I know I can turn the warning off. I was trying to substitute my own warning. Some users won't even know what a "record" is. They will know what a "Patient" is though and I'd like the warning to reflect that. John |
#8
|
|||
|
|||
Arvin,
You have no idea of the hurdles we're going through with the HIPPA Guidelines! The people who will be using this database are ALL physicians (residents and interns actually) and are intimately aware of these rules. Trust me, the IS people at our facility who will be responsible for deploying the database hospital-wide are also fully aware of it as well. Lots and lots of committees! John "Arvin Meyer" wrote in message ... You may want to take a look at the BeforeDelConfirm event which can be cancelled should you decide not to delete the record. If it is cancelled, the warning message won't appear. If not, you can SetWarnings False and proceed with the deletion. I never allow most users to delete records, so I haven't spent much time working with these events. My preference is to mark records to not be displayed, then requery the recordsource so that the "deleted" record is no longer seen. It's more trouble in the beginning, but far less than having a clueless user (or worse, a malicious user) run amok in the database. BTW, I see the word "Patient" and notice that you are an MD, so I am assuming that you are building a medical database. Access security must be strictly adhered to to achieve compliance with HIPPA laws. It is important, that you spend adequate time teaching your users what a "record" is and the nuances of patient privacy, as well as protection of the personal financial information. When you are nearing completion of your project, be sure to get a security audit to make sure you and your patients are protected. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access Downloads http://www.datastrat.com http://www.mvps.org/access "John S. Ford, MD" wrote in message ... Right Doug, I know I can turn the warning off. I was trying to substitute my own warning. Some users won't even know what a "record" is. They will know what a "Patient" is though and I'd like the warning to reflect that. John |
#9
|
|||
|
|||
Since I am both a database developer and a security consultant, I am well
aware of the hoops you are being forced to jump through. In my experience, the biggest obstacle to easy HIPPA compliance are the insurance companies. They are convinced that their databases and their procedures help them eliminate fraud. Were I a crook, I'd be in bed with the insurance companies because their insistence on data collection is the biggest contributor to the proliferation of fraud there is. The medical professions must now walk a very narrow line between legal compliance and providing insurance companies with the data they desire before they will pay. I don't envy your position at all. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access "John S. Ford, MD" wrote in message ... Arvin, You have no idea of the hurdles we're going through with the HIPPA Guidelines! The people who will be using this database are ALL physicians (residents and interns actually) and are intimately aware of these rules. Trust me, the IS people at our facility who will be responsible for deploying the database hospital-wide are also fully aware of it as well. Lots and lots of committees! John "Arvin Meyer" wrote in message ... You may want to take a look at the BeforeDelConfirm event which can be cancelled should you decide not to delete the record. If it is cancelled, the warning message won't appear. If not, you can SetWarnings False and proceed with the deletion. I never allow most users to delete records, so I haven't spent much time working with these events. My preference is to mark records to not be displayed, then requery the recordsource so that the "deleted" record is no longer seen. It's more trouble in the beginning, but far less than having a clueless user (or worse, a malicious user) run amok in the database. BTW, I see the word "Patient" and notice that you are an MD, so I am assuming that you are building a medical database. Access security must be strictly adhered to to achieve compliance with HIPPA laws. It is important, that you spend adequate time teaching your users what a "record" is and the nuances of patient privacy, as well as protection of the personal financial information. When you are nearing completion of your project, be sure to get a security audit to make sure you and your patients are protected. -- Arvin Meyer, MCP, MVP Microsoft Access Free Access Downloads http://www.datastrat.com http://www.mvps.org/access "John S. Ford, MD" wrote in message ... Right Doug, I know I can turn the warning off. I was trying to substitute my own warning. Some users won't even know what a "record" is. They will know what a "Patient" is though and I'd like the warning to reflect that. John |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Substituting my own MsgBox for the standard delete confirm MsgBox | John S. Ford, MD | General Discussion | 8 | August 20th, 2004 12:05 AM |
Implementing a Save, Delete or Cancel MsgBox | Van T. Dinh | General Discussion | 1 | August 19th, 2004 01:42 PM |
Delete without Confirm | Kris L. | Using Forms | 2 | July 14th, 2004 04:15 PM |