Yes / No Message Box

R

rye1982

My form is used for entering records.

When a user clicks a button to submit one, I want a pop-up box to load up
saying "Would you like to enter another record?" with Yes or No options
listed below. If yes, a new blank record loads up, if no, the form closes.

How can I do this? (I am a bit of an Access novice so if you could be basic
in your answer - i.e. where to place code, etc. that would be great)

Thanks!
 
K

Klatuu

If MsgBox("Would you like to enter another record?", vbQuestion +
vbYesNo) = vbYes Then
Docmd.GotoRecord acNewRec
Else
Docmd.Close acForm, Me.Name, acSaveNo
End If
 
R

rye1982

Thank you very much.
Where/how do I input this code into Access 2007?
I am getting a "can't parse the expression" error when I input it into the
code into the Expression Builder for my button.
Could you explain the naming of each portion of the code as well? (ie. what
should me.Name be in my database?)

Ryan
 
R

rye1982

I am getting a "can't parse the expression" error when I input it into the
code into the Expression Builder for my button. What could be causing this?
Could you explain the naming of each portion of the code as well? (ie. what
should me.Name be in my database?)
 
K

Klatuu

It goes in the Code Builder, Not the expression builder.
In the properties dialog for the command button click event, delete whatever
you have in the On Click event text box.
Click the small button with 3 dots next to the text box.
Select Code Builder
Paste the code in there.

The code needs no change, Me.Name returns the name of the form as a string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Yes/No Box 5
Pop Up Form Focus Question 2
Macro doesn't work first time form is opened. 2
Form Not Loading with Records One User 1
No fields in SubForm 16
Additions Denied 4
Message Box 5
Yes/No Format Issue 2

Top