By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,482 Members | 2,438 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,482 IT Pros & Developers. It's quick & easy.

My code wont work Why?

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Nov 12 '05 #2

P: n/a
Thanks Don works just fine I'm using A20000
Tony
"Don Leverton" <le****************@telusplanet.net> wrote in message
news:O%3bc.48$B16.37@edtnps89...
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


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.