Hello,
I am using Access 2003 I have a database I have created for a church cemetery. It has approximately 425 records. I created a form that I can query a last name and bring up the form if the record exists. If no record is found, a MSG box will say it doesn't exist. I added some code to search again and it works when I say yes to continue searching. If after more than one new search within this code, it will error out at the 'DoCmd.OpenForm "Form Query LAST NAME" if I say NO. If I click the NO after the first search, it works fine.
Any help would be greatly appreciated. The code is as follows.
Thanks!
Private Sub Form_Open(Cancel As Integer)
Dim NewSearch
StartSearch:
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
NewSearch = MsgBox("There is no record of this person in this cemetery. Search again?", vbYesNo)
If NewSearch = vbYes Then
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Form Query LAST NAME"
GoTo StartSearch
Else
DoCmd.Close acForm, Me.Name
Exit Sub
End If
End If
End Sub
I am using Access 2003 I have a database I have created for a church cemetery. It has approximately 425 records. I created a form that I can query a last name and bring up the form if the record exists. If no record is found, a MSG box will say it doesn't exist. I added some code to search again and it works when I say yes to continue searching. If after more than one new search within this code, it will error out at the 'DoCmd.OpenForm "Form Query LAST NAME" if I say NO. If I click the NO after the first search, it works fine.
Any help would be greatly appreciated. The code is as follows.
Thanks!
Private Sub Form_Open(Cancel As Integer)
Dim NewSearch
StartSearch:
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
NewSearch = MsgBox("There is no record of this person in this cemetery. Search again?", vbYesNo)
If NewSearch = vbYes Then
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Form Query LAST NAME"
GoTo StartSearch
Else
DoCmd.Close acForm, Me.Name
Exit Sub
End If
End If
End Sub