sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
DD's Avatar

Search by Date


Question posted by: DD (Guest) on November 12th, 2005 06:25 PM
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
1 Answer Posted
Jim Allensworth's Avatar
Guest - n/a Posts
#2: Re: Search by Date

On 1 Jan 2004 22:01:49 -0800, Join Bytes! (DD) wrote:
[color=blue]
>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[/color]

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
 
Not the answer you were looking for? Post your question . . .
196,919 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,919 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors