Save Command?

  • Thread starter Thread starter Doctor
  • Start date Start date
D

Doctor

I need to put a save command inside an If Not statement. I've tried a lot of
things but can't get it to work. The one here in my original code is old.
What should it look like.

Public Sub cmdSave_Click()
' Put focus on "key" control
Me.ContactFirstName.SetFocus
If Not SaveIt() Then Exit Sub
DoCmd.Close acForm, Me.Name

End Sub
 
You did not post the code for SaveIt() nor the values it returns. Based on
how you are using it, it should return a boolean value.
 
I need to put a save command inside an If Not statement. I've tried a lot of
things but can't get it to work. The one here in my original code is old.
What should it look like.

Public Sub cmdSave_Click()
' Put focus on "key" control
Me.ContactFirstName.SetFocus
If Not SaveIt() Then Exit Sub
DoCmd.Close acForm, Me.Name

End Sub

What are you trying to save, and how? As Klatuu says, none of us can see your
SaveIt() routine.

Note that the Save command in VBA saves *design changes to the structure of a
form* - if you're trying to save a record to disk, you would NOT use a Save
command, but rather either

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False
 
Thanks. The Me.Dirty did what I needed it to. I had previously tried the save
command, but I got an error once the date in this form updated on another
form.
 
Back
Top