Form_BeforeUpdate

R

reservedbcreater

i have a button called next, which goes to the next form of the suvey
when clicked i want it to trigger this event:
(what code do i put int the next button(which currently has no code) click
event to trigger it)

Private Sub Form_BeforeUpdate(Cancel As Integer)

dim intResponse2 as integer
Dim strDocName As String
Dim intResponse As Integer
Dim strID As String

strDocName = "Water"

intResponse = MsgBox("Save Record?", vbYesNoCancel)

Select Case intResponse
Case vbYes
intResponse2 = MsgBox("Go to next page", vbYesNo)
Select Case intResponse2
Case vbYes
strID = Me.ID
DoCmd.Close
DoCmd.OpenForm strDocName
Forms(strDocName)!ID = strID
End Select
Case vbNo
Me.Undo 'To undo the edit
Case vbCancel
Cancel = True 'To cancel the update & hence the close
End Select

End Sub
 
G

Graham Mandeno

The Form_BeforeUpdate procedure will be automatically called if you try to
save the current record. To do this in code, use either:
DoCmd.RunCommand acCmdSaveRecord
or
Me.Dirty = False
or you can just navigate to another record:
DoCmd.GotoRecord ...
 

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

Top