Hi,
I'm fairly new to Access / VBA and have been trying relentlessly to get a text box / search button on my Access form to pull up a specific record. Although the null command produces the correct error msgBox, it does not show any record if I enter a correct primary key term. Probably something really simple, but I am completely stuck and cannot find the solution anywhere.
Search button = SearchButton1
Search criteria = SearchText1
Primary key field = UniqueAEVRef
Code:
Please help!
I'm fairly new to Access / VBA and have been trying relentlessly to get a text box / search button on my Access form to pull up a specific record. Although the null command produces the correct error msgBox, it does not show any record if I enter a correct primary key term. Probably something really simple, but I am completely stuck and cannot find the solution anywhere.
Search button = SearchButton1
Search criteria = SearchText1
Primary key field = UniqueAEVRef
Code:
Code:
Private Sub SearchButton1_Click()
If IsNull(SearchField1) = False Then
Me.Recordset.FindFirst "[UniqueAEVRef]='" & SearchField1 & "'"
Me!SearchField1 = Null
If Me.Recordset.NoMatch Then
MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
Me!SearchField1 = Null
End If
End If
End Sub
Please help!