Message box

jac 1

New member
Local time
Today, 07:01
Joined
Aug 11, 2009
Messages
3
I would like to be able to have a message box pop up asking the user if they wish to delete current information when they attempt to enter new information into a form that has been populated. Is there a way short of
making the form "Read Only"?

Thank you

jac 1
 
Make an event and then

Dim iResponse as integer
iResponse = MsgBox "Do you wish to delete etc",vbQuestion + vbYesNo","More Text"
if iResponse <> 6 then ' 6 is Yes
Exit Sub
else
' Do your delete
end if
 
Make an event and then
MAKE an event? I think you might want to explain yourself a little better Ted. You should have chosen to say choose an event, not make an event. But you have to choose the right event or else it doesn't work correctly.
Dim iResponse as integer
iResponse = MsgBox "Do you wish to delete etc",vbQuestion + vbYesNo","More Text"
if iResponse <> 6 then ' 6 is Yes
Exit Sub
Also, you can use Access CONSTANTS so you don't need to know that 6 is Yes. Just use vbYes and it is much easier for everyone to see what you mean. And you do not need to assign the output to a variable. It is okay to do but is extraneous code.

A simple:
Code:
If MsgBox("Do you wish to delete the data and start fresh?", vbQuestion + vbYesNo, "Confirm") = vbYes Then
    '...do your delete stuff here
End If
works great.

However, now that has been said, you really should just have it as read-only and have a button to switch to edit mode. Trying to code for what you have said - when someone starts to change the record would be a pain. You would need to start with the form's On Dirty event and then you would need to possibly undo changes because the change would have already been started.

So, just set the form to read only in the form's on Current event:
Code:
Me.AllowEdits = False
Me.AllowDeletions = False
and then in a click event of a button
Code:
Me.AllowEdits = True
Me.AllowDeletions = True
 
Thanks Ted and Bob. I tried as you said. Placed and edit button on form and it
works great.

Thanks to all for your help. Jac 1
 

Users who are viewing this thread

Back
Top Bottom