G
Guest
hello,
I have a database created with many records. On the main form I have an
unbound object created to allow the user to enter a number and then have
created a button so that the user can click to search the database and if the
record matches all the record details are displayed.
My problem is that if there are no matching details the user is just
presented with a blank screen and one needs to X from it to return to the
search screen. I would like to build a small bit of error coding to let the
user know that no record was found and then retun the user to the main search
screen.
I realise that this may be a primitive way to perform a search however I
dont have much time or experience to play around with it.
The code from the search button is belows & it would be great is somebody
could let me know If I can add in some bit of code to carry out the above.
Thanks
Resume Exit_Search_for_Record_Click
End Sub
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Archived Current"
stLinkCriteria = "[Reg No]=" & "'" & Me![Text0] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
Private Sub Close_Search_Screen_Click()
On Error GoTo Err_Close_Search_Screen_Click
DoCmd.Close
Exit_Close_Search_Screen_Click:
Exit Sub
Err_Close_Search_Screen_Click:
MsgBox Err.Description
Resume Exit_Close_Search_Screen_Click
End Sub
Phil
I have a database created with many records. On the main form I have an
unbound object created to allow the user to enter a number and then have
created a button so that the user can click to search the database and if the
record matches all the record details are displayed.
My problem is that if there are no matching details the user is just
presented with a blank screen and one needs to X from it to return to the
search screen. I would like to build a small bit of error coding to let the
user know that no record was found and then retun the user to the main search
screen.
I realise that this may be a primitive way to perform a search however I
dont have much time or experience to play around with it.
The code from the search button is belows & it would be great is somebody
could let me know If I can add in some bit of code to carry out the above.
Thanks
Resume Exit_Search_for_Record_Click
End Sub
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Archived Current"
stLinkCriteria = "[Reg No]=" & "'" & Me![Text0] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
Private Sub Close_Search_Screen_Click()
On Error GoTo Err_Close_Search_Screen_Click
DoCmd.Close
Exit_Close_Search_Screen_Click:
Exit Sub
Err_Close_Search_Screen_Click:
MsgBox Err.Description
Resume Exit_Close_Search_Screen_Click
End Sub
Phil