Referencing unbound text box in expressions

Ron in NYC

Registered User.
Local time
Yesterday, 23:00
Joined
Mar 4, 2016
Messages
30
I'm not sure what the problem is with the expression, but it's not working even though I used the expression builder to create it.

I'm doing a range of calculations on hours worked by project. To do this I create a query with Total hours for the period, and another for hours by project. I then divide the hours by project by the total hours to cacluate the percent of time spend on each project for the company. I do many subsets of this calculation as well. I do one for each of our offices, and for each individual staffer.

The way I've always done it is to put in the query's critera something that prompts me: Between [Enter the start date] and [Enter the end date], but I have to enter that multiple times and I'd like to just change the dates and have the queries work for the new period.

So I created a form with two unbound text boxes and used the expression builder to put the query date criteria as

Between [Forms]![Main]![Text0] and [Forms]![Main]![Text2].

But I get no records. The name of the form is "Main." I have it open and populated the text0 with 4/1/2016 and text2 with 4/30/2016. It should get a bunch of records but gets none.

What's wrong with my expression?
 
I should add: when I do it the old way, Between [Enter start date] and [Enter end date] it works. But it would be so much easier if all the queries could just pull the same parameters from the form.
 
does the field you want to query include time value?
 
To debug this I suggest putting some additional expressions in your query and then just run the query when the form is open to see if the references are working. The expressions you would put in the field of the query would be:

Expr1: CStr([Forms]![Main]![Text0])

and

Expr2: CStr([Forms]![Main]![Text2])

You can see how I did this in the attached database.
 

Attachments

Thanks for your help.

It turns out that I have to save the form or hit the return key after I enter the dates into the unbound text boxes. It works fine.
 

Users who are viewing this thread

Back
Top Bottom