Greetings,
On a data entry form, I have a command button that opens another form that prompts the user to enter search criteria to pull up old records. The other form re-opens the main data entry form with the criteria as expected. This works great unless the main form is in add-mode. If so, I get the following error: "Runetime 2501. The OpenForm action was canceled."
So to get around that, I figured the best way to be to cancel the users current data entry of they hit the command button that opens the search form. Are there any properties or methods that would accomplish this? Here is the code I'm working with:
Data Entry form command button:
Search Form command button:
Thanks in advance for the help!
~Melagan
______
"It's never too late to become what you might have been.
On a data entry form, I have a command button that opens another form that prompts the user to enter search criteria to pull up old records. The other form re-opens the main data entry form with the criteria as expected. This works great unless the main form is in add-mode. If so, I get the following error: "Runetime 2501. The OpenForm action was canceled."
So to get around that, I figured the best way to be to cancel the users current data entry of they hit the command button that opens the search form. Are there any properties or methods that would accomplish this? Here is the code I'm working with:
Data Entry form command button:
Code:
Private Sub cmdFind_Click()
'gstrFormName declarred globally
gstrFormName = Me.Form.Name
DoCmd.OpenForm "frmSearch", acNormal
End Sub
Search Form command button:
Code:
Private Sub cmdOK_Click()
'gstrFormName declared globally.
Dim blnFound As Boolean
blnFound = Nz(DLookup("[Escrow Number]", "Escrows", "[Escrow Number] = '" & Me.txtSearch.Value & "'"), False)
If blnFound = False Then
MsgBox "Escrow number " & Me.txtSearch.Value & " not found in database.", _
vbInformation, "NATTrack"
Else
DoCmd.OpenForm gstrFormName, acNormal, , "[Escrow Number] = '" & Me.txtSearch.Value & "'"
DoCmd.Close acForm, "frmSearch", acSaveNo
End If
End Sub
Thanks in advance for the help!
~Melagan
______
"It's never too late to become what you might have been.