F
Froto
I have the following code behind the onclick event of a
button
Private Sub cbodate_Click()
Dim strdate As String
Dim strSearch As String
'Check for value in date box
If IsNull(Me![txtdate]) Or (Me![txtdate]) = "" Then
MsgBox "Please enter a Date for your search!",
vbOKOnly, "Invalid Search Criterion!"
Me![txtdate].SetFocus
Exit Sub
End If
'---------------------------------------------------------
---------------------------
'Perform the search from the set value in txtdate
DoCmd.ShowAllRecords
DoCmd.GoToControl ("Date")
DoCmd.FindRecord Me!txtdate
Date.SetFocus
strdate = Date
txtdate.SetFocus
strSearch = txtdate
'If matching record found show MsgBox and clear Control
If strdate = strSearch Then
MsgBox "Records found matching your Search:" &
strSearch, , "Valid Search!"
Date.SetFocus
txtdate = ""
'If values not found sets focus back to search box and
shows message
Else
MsgBox "No Records found matching your date selection:" &
strSearch & "Please Try Again.", , "Invalid Search
Criterion!"
txtdate.SetFocus
End If
End Sub
What's happening is the search is showing all records,
and not only the ones from the text box value, what do i
need to change to make this work
Thank you
button
Private Sub cbodate_Click()
Dim strdate As String
Dim strSearch As String
'Check for value in date box
If IsNull(Me![txtdate]) Or (Me![txtdate]) = "" Then
MsgBox "Please enter a Date for your search!",
vbOKOnly, "Invalid Search Criterion!"
Me![txtdate].SetFocus
Exit Sub
End If
'---------------------------------------------------------
---------------------------
'Perform the search from the set value in txtdate
DoCmd.ShowAllRecords
DoCmd.GoToControl ("Date")
DoCmd.FindRecord Me!txtdate
Date.SetFocus
strdate = Date
txtdate.SetFocus
strSearch = txtdate
'If matching record found show MsgBox and clear Control
If strdate = strSearch Then
MsgBox "Records found matching your Search:" &
strSearch, , "Valid Search!"
Date.SetFocus
txtdate = ""
'If values not found sets focus back to search box and
shows message
Else
MsgBox "No Records found matching your date selection:" &
strSearch & "Please Try Again.", , "Invalid Search
Criterion!"
txtdate.SetFocus
End If
End Sub
What's happening is the search is showing all records,
and not only the ones from the text box value, what do i
need to change to make this work
Thank you