G
Guest
I have one button that is the "exit" button for my data entry form. The idea
is that people can enter data directly to the linked table (create a new
record and add info) and then return to the previous search form. For some
reason, the information isn't being saved to the table before it returns to
the search form. Anyone have any ideas why? Code begins (break lines
added for clarity):
Option Explicit
------------------------------------------------------
Private Sub cmdBackToSearch_Click()
On Error GoTo Err_cmdBackToSearch_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close
stDocName = "frmSearch"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdBackToSearch_Click:
Exit Sub
Err_cmdBackToSearch_Click:
MsgBox Err.Description
Resume Exit_cmdBackToSearch_Click
End Sub
--------------------------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Do you wish to save the changes?"
strMsg = strMsg & " Click Yes to save record or No to exit without
saving."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save this Record?") = vbYes Then
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
----------------------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
is that people can enter data directly to the linked table (create a new
record and add info) and then return to the previous search form. For some
reason, the information isn't being saved to the table before it returns to
the search form. Anyone have any ideas why? Code begins (break lines
added for clarity):
Option Explicit
------------------------------------------------------
Private Sub cmdBackToSearch_Click()
On Error GoTo Err_cmdBackToSearch_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close
stDocName = "frmSearch"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdBackToSearch_Click:
Exit Sub
Err_cmdBackToSearch_Click:
MsgBox Err.Description
Resume Exit_cmdBackToSearch_Click
End Sub
--------------------------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Do you wish to save the changes?"
strMsg = strMsg & " Click Yes to save record or No to exit without
saving."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save this Record?") = vbYes Then
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
----------------------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub