cmdSearch_Click

G

Guest

I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch
'and evaluates this against values in strStudentID

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL As 2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub
 
G

Guest

tmaxwell said:
I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch
'and evaluates this against values in strStudentID

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top