Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save button problem

Status
Not open for further replies.

DrewConn

Programmer
Jan 8, 2002
167
0
0
US
I have a save record button on a form. The problem is that a message box pops up asking is you want to update the record. If you select yes everything is fine, if you select no however, all of the data on the form is cleared.

What I need is when you select no for the data to remain in all of the controls, just dont write the data to the table.

The code I have now in the click event is:

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec

Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub





 
Remove the DoCmd.GoToRecord,,AcNewRec and force the user to add a new record manually is one of your options

HTH
Mike

[noevil]
 
Where is your message box. I think it would work if you only executed the save code when the message box is 'yes':

Code:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

   if MsgBox result = vbYes then
      DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
      DoCmd.GoToRecord , , acNewRec
   End If
   

Exit_cmdSave_Click:
    Exit Sub

Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click
    
End Sub


-Gary
 
I have a slight variation on this issue. As suggested above, I am using DoCmd.GoToRecord , , acNewRec, but it never goes to a 'new record'.

Couple of items to note:
1. Using a data entry form - can I even go to a new form?
2. When users click the Save button, three SQL queries run in the background to populate the record. I don't use the Access save command (DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70). Don't know if this matters, but wanted to tell you up front.

Any ideas on what I am doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top