If statement

T

Tony Williams

I have an If statement that checks if the user has entered a new record.
Here is my code

If Me.NewRecord Then
If vbYes = MsgBox("Do you want to save any changes you have made to this
record?", 36, "Enter New Record") Then
DoCmd.Requery "Docnumtxt"
DoCmd.RunCommand acCmdSaveRecord
Else
Me.Undo
Cancel = True
End If
End If
End If
DoCmd.Close
End If

How do I use the Else statement to check if it isn't a new record?
Thanks IA
Tony Williams
 
J

JulieD

Hi Tony

see below:

If Me.NewRecord Then
If vbYes = MsgBox("Do you want to save any changes you have made to this
record?", 36, "Enter New Record") Then
DoCmd.Requery "Docnumtxt"
DoCmd.RunCommand acCmdSaveRecord
Else
Me.Undo
Cancel = True
End If
ELSE
'WHATEVER YOU WANT TO DO IF Me.NewReocord = False
End If
End If - not sure what this end if relates to
DoCmd.Close
End If - not sure what this end if relates to

Hope this helps

Cheers
JulieD
 
T

Tony Williams

Works just great Julie!!!!
Thanks again
Tony
JulieD said:
Hi Tony

see below:

If Me.NewRecord Then
If vbYes = MsgBox("Do you want to save any changes you have made to this
record?", 36, "Enter New Record") Then
DoCmd.Requery "Docnumtxt"
DoCmd.RunCommand acCmdSaveRecord
Else
Me.Undo
Cancel = True
End If
ELSE
'WHATEVER YOU WANT TO DO IF Me.NewReocord = False
End If


Hope this helps

Cheers
JulieD
 

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


Top