By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

Search by Date

P: n/a
DD
I have the following code,
The user needs to search by any date they enter into a searchbox, my
code is not working!
Can someone give me a hint or??
Regards

Code
Private Sub cmdFind_Click()
Dim strTable As String
Dim strField As String
Dim strCriteria As String

strCriteria = "*" & txtCriteria & "*"
On Error GoTo FindErr

Select Case OptSearch
Case 1
Me![frmSiteFilter].Form.Filter = "[ShipNumber] Like '*" &
txtCriteria & "*'"
Case 2
Me![frmSiteFilter].Form.Filter = "[ShipDate]='#" &
txtCriteria & "#'"

End Select
Me![frmSiteFilter].Form.FilterOn = True
Exit Sub
FindErr:
Beep
Me![frmSiteFilter].Form.Filter = ""
Me![frmSiteFilter].Form.FilterOn = False
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 1 Jan 2004 22:01:49 -0800, da**********@bigpond.com.au (DD) wrote:
I have the following code,
The user needs to search by any date they enter into a searchbox, my
code is not working!
Can someone give me a hint or??
Regards

Code
Private Sub cmdFind_Click()
Dim strTable As String
Dim strField As String
Dim strCriteria As String

strCriteria = "*" & txtCriteria & "*"
On Error GoTo FindErr

Select Case OptSearch
Case 1
Me![frmSiteFilter].Form.Filter = "[ShipNumber] Like '*" &
txtCriteria & "*'"
Case 2
Me![frmSiteFilter].Form.Filter = "[ShipDate]='#" &
txtCriteria & "#'"

End Select
Me![frmSiteFilter].Form.FilterOn = True
Exit Sub
FindErr:
Beep
Me![frmSiteFilter].Form.Filter = ""
Me![frmSiteFilter].Form.FilterOn = False


You are setting ShipDate as a string. It is surrounded by single
quotes - try removing those.

Me![frmSiteFilter].Form.Filter = "[ShipDate]=#" &
txtCriteria & "#"

Now it is a date literal.

- Jim
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.