Are you sure you want to save message

colinmunnelly

Registered User.
Local time
Today, 19:57
Joined
Feb 26, 2002
Messages
89
Thanks to everyone for all your help.
I have yet another problem (got loads more yet) it is:

I have a form and once the user has filled in all the required fields and attemps to either close the form or goes to enter a new record a message box appears asking them are they sure they want to enter the data and save the record. Is this possible??

Thanks again. Thank god for you people on here!!
 
You might end up having to put the code in two or three places, on the BeforeUpdate event of the form, the Close button and an Add button if you have one. For the close button you could do something like:

Dim stdResponse as integer
dim cancel

stdresponse = MsgBox ("Do you want to save this record before you close the form",vbyesno

if stdresponse = vbyes then
Docmd.close 'the record saves automatically

else
cancel = true
Me.undo
Docmd.close
End If
End If
 
Thanks for your reply.

Got me thinking what might be a better idea and you may be able to tell me if its possible. I want to have to press a save button in between record entries. So would it be possible to place a button on the form and when pressed save the current record and go on to the next. So you were not able to input another record if the save button isn't pressed.

Thanks again
 
Try the following in between the buttons click event.


Dim intButSelected As Integer, intButType As Integer
Dim strMsgPrompt As String, strMsgTitle As String

strMsgPrompt = "Are you sure you want to save"
strMsgTitle = "!!"

intButType = vbYesNo + vbDefaultButton1
intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)

If intButSelected = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70' YES button code...

Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70' NO button code...
End If

Dave
 
DW.
DoMenuItem is virtually extinct within Access, better replaced with the RunCommand equivalents. Sadly several of both DoMenuItem and their RunCommand alternatives don't work on PopUp and Modal forms so if you want to maintain control of your application you'll have to use Me. method.
 
Thanks for your reply dave. I have used your code and now get an error message after the Msgbox appears saying 'The command or action "Undo" isn't avaliable now. Any Ideas
 
Thanks Rich for your response. But im afraid your answer went right over my head. Pretty new at messing with vb so you will have to be patient. Again thanks for your time on this boys and girls...
 
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Msg, Style, Title, Response, MyString
Beep
Msg = "Do you wish to save this record? "
Style = vbYesNo + vbExclamation + vbDefaultButton1 ' Define buttons.
Title = "Confirm Save" '
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
Me.Undo
Exit Sub
DoCmd.RunCommand acCmdSaveRecord
End If
End Sub
 
Thanks Rich for your reply. Where do i put this code? Appreciate the patience your showing.

Col
 

Users who are viewing this thread

Back
Top Bottom