In a stock form i have set apart a text box with row source connected to a table/query to display all the 'code numbers' available. I used the following code to display a search:
Code:
Private Sub cmdsearch_Click()
Dim reference As String
Dim strSearch As String
If IsNull(Me![txtsearch]) Or (Me![txtsearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtsearch].SetFocus
Exit Sub
End If
DoCmd.ShowAllRecords
DoCmd.GoToControl ("CodeNumber")
DoCmd.FindRecord Me!txtsearch
CodeNumber.SetFocus
reference = CodeNumber.Text
txtsearch.SetFocus
strSearch = txtsearch.Text
If reference = strSearch Then
MsgBox "PRODUCT FOUND!: " & strSearch, , "Successfull!"
CodeNumber.SetFocus
txtsearch = ""
Else
MsgBox "PRODUCT DOESN'T EXIST!: " & strSearch & " - Try Again.", _
, "Invalid Search Criterion!"
txtsearch.SetFocus
End If
End Sub
I need to replace the bold code so instead calling "showallrecords", the values written in "txtsearch" field, run through a query and then loaded the details in stock form. Any ideas? Hope i explained myself right
Thanks