I was hoping someone could help me here.
I've got a form that a user enters a map number into. I want to check a master list of map numbers (stored in a table) to see if it exists. I'd like something of a true/false answer so I can then direct the user to the next appropriate form. Right now I just send the user to a form and then refresh the list boxes on the form based on the number provided. If the map number is new or wrong it just shows an empty form. I'd rather have something that checks the table ahead of time and pops up a message box if no record exists. Here is my current code:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim frm As Form, txt As TextBox
Dim frm2 As Form, txt2 As TextBox, txt3 As TextBox
stDocName = "search_records"
stLinkCriteria = "[MAP_NUMB]='" & Me.strMap & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Set frm = Forms![search_records]
Set txt = Forms![search_records]!Text1
frm.RefreshLists
frm.SetFocus
txt.SetFocus
End If
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.description
Resume Exit_Command0_Click