Hi Tony,
I'm assuming that you're using Access97 or newer here, correct?
I hate that Access95 DoMenuItem crap ... try using the form's "Dirty"
property instead ... like this:
If Msgbox("Are you sure you want to save this new record?", vbYesNo) =
vbYes Then
'If the user clicks Yes, this "saves" the current record
Me.Dirty = False
Else
'If the user clicks No, this "un-does" the changes to the current
record.
Me.Undo
'Now, "nest" your other "If" statement here ... so that this msg is only
displayed if the user clicks No in the first msg.
If MsgBox("Would you like to input something else?", vbYesNo) =
vbYes Then
Me.[DocNametxt].SetFocus
Else
DoCmd .Close
End If
End If
--
HTH,
Don
=============================
Use
My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)
I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.
=============================
"Tony Williams" <tw@tcp.invalid> wrote in message
news:c4**********@hercules.btinternet.com...
I have this code behind a command button but it doesn't delete the record.
If vbNo = MsgBox("Are you sure you want to save this new record?", 4) Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
If vbYes = MsgBox("Do you want to input another record?", 4) Then
[DocNametxt].SetFocus
End If
DoCmd.Close
I've also tried
DoCmd.RunCommand acCmdDeleteRecord
But this didn't work either
Anyone help me with why?
TIA
Tony Williams