|
-
Jul 5th, 2005, 02:15 PM
#1
Thread Starter
Frenzied Member
Slightly OT: Need help with a criteria expression (Access) [Resolveed]
Hey,
I am designing a query using Access query builder. The criteria of the query is 2 dates coming from 2 text boxes on a form inside the DB.
this is the criteria that I have:
Between [Forms]![Reports_Form]![startDate].[text] And [Forms]![Reports_Form]![endDate].[text]
When I run this from the form the results are blank. Anyone know what I am doing wrong here?
PS: Posted this in the Database section with little help, figured I would try here.
Thanks
Last edited by Besoup; Jul 6th, 2005 at 08:01 AM.
-
Jul 5th, 2005, 03:52 PM
#2
Frenzied Member
Re: Slightly OT: Need help with a criteria expression (Access)
I don't actually use the query builder, just the SQL view or buld it in code, but a couple possible things.
Do your textboxes have values? This means the form has to be open. You can't just build the query and run it like you could if you referred to actual values.
Second, and here I don't know about the query builder, are you querying correct data types? I'm guessing start_date & end_date are date fields in your table, but you're passing in strings from a textbox. You'd have to convert the strings to a date type, with # signs or CDate() - BETWEEN #Forms!Report_Forms...#. If you built your SQL in code, it would look something like this:
VB Code:
strSQL = "SELECT fldFoo FROM tblFoo WHERE fldDate BETWEEN #" & _
[Forms]![Reports_Form]![startDate].[text] & "# AND #" & _
[Forms]![Reports_Form]![endDate].[text] & "#"
If for some reason the date fields are actually text data types, the example I gave would replace the # signs with single quotes. But since they wouldn't then be actual dates, looking BETWEEN them would be pretty futile. Maybe it would do some ascii or binary comparison, but even if so, probably not the results you want.
Tengo mas preguntas que contestas
-
Jul 6th, 2005, 03:05 AM
#3
Re: Slightly OT: Need help with a criteria expression (Access)
See your other thread in Databases Forum...
[edit]
Hmm Yeah forgot about the hashes, add those in too
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|