stay on record after save

Seasider

New member
Local time
Today, 12:44
Joined
Jan 5, 2003
Messages
33
In the BeforeUpdaate event on a form, I have a message box that prompts the user to confirm that they want to save the record. If vbYesNo = yes, the record saves properly but after the record is saved the form moves to the first record. How can this be coded so that the form stays on the current record that was just saved?

Any assistance is greatly appreciated.
 
How are you initiating the call to Before_Update()?

If you are paging to the next record using the navigation arrows on your form, then the next record will display....
 
stay on same record

Thanks for responding. I'm stumped on this one.

I have a SAVE command button on the form with this code:

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunCommand acCmdSave
Me.Form.Requery


Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub



I also have this is the code in the Before_Update of the Form so user can confirm if they want to go on to save or to undo the changes

If MsgBox("Do you want to save the changes?", vbYesNo + vbQuestion, "SAVE CURRENT RECORD?") = vbNo Then
DoCmd.RunCommand acCmdUndo
End If

Don't know how to get it to stay on the record I am saving. Any assistance would be appreciated.

Seasider
 
not paging to next record

sorry, I didn't answer your question directly. I am saving by clicking the save command button and not any other navigation buttons.

Thanks
 
Try commenting out the line :

Me.Form.Requery

(This is refreshing the form and will reload the first record of the recordsource it comes to - unless you are using filters in the Current() event....)
 
stay on same record

Hello GJT,

thanks again for responding. My problem is precicely that after I save, it goes to the first record in the record source. I want it to stay on the record I am saving. For example, if I am saving changes to record 6, then I want the form to stay opened at that record and not go to the first record in the set.

I don't know what to put in the Current event.

Thanks
Seasider
 
Have you tried commenting out the line mentioned above?
 
stay on same record

Thanks GJT,

Yes, I have commented out that line but it doesn't change anything.

Seasider
 
solution found

GJT,

Thanks for your efforts. I found the solution elsewhere in this forum. The following code works:

DoCmd.RunCommand acCmdSaveRecord

The code I was using
DoCmd.RunCommand acCmdSave
was obviously saving the whole recordset (if that makes any sense). The code above saves the current record and stays on that record.

Thanks
Seasider
 

Users who are viewing this thread

Back
Top Bottom