I would like to have a search box/form activate from a form when a button is clicked. The search box would clear the main form and fill it with the record that gets entered into the search box. I have tried the following code but does not work. The main form is called [Prisoner_Details] and the field I am using to search on is [Spin]. when this code is used on the button click of the main form a box appears but when I enter data in to its search field I get the message "invalid use of NUll".
Private Sub cmdFind_Click()
On Error GoTo Err_cmdFind_Click
Dim answer As String
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Prisoner_Details"
answer = InputBox("Enter the Spin Number you wish to search for", "Find on Spin")
stLinkCriteria = "[Spin]= answer
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdFind_Click:
Exit Sub
Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click
End Sub
Private Sub cmdFind_Click()
On Error GoTo Err_cmdFind_Click
Dim answer As String
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Prisoner_Details"
answer = InputBox("Enter the Spin Number you wish to search for", "Find on Spin")
stLinkCriteria = "[Spin]= answer
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdFind_Click:
Exit Sub
Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click
End Sub