View Full Version : Query not picking up a value from form


Atomic Shrimp
06-30-2009, 05:47 AM
I've got a form (frmMain) with a combo on it (Combo33) - the combo is looking up billing periods from a tblBillingPeriods (bound column is BillingPeriodID).

I have a query that includes tblBillingPeriods (joined to a transaction history table) and the column BillingPeriodID. The criterion applied to the BillingPeriodID column is =[Forms]![frmMain]![Combo33]

So the query should return rows where the billing period matches the one selected in the combo.

But it doesn't - it comes back empty, however, if I type ? [Forms]![frmMain]![Combo33] in the VBA immediate window, it returns 44

If I put = 44 as the criterion under BillingPeriodID in my query, it works.

What is going on?

Atomic Shrimp
06-30-2009, 05:56 AM
If I forget the criteria and add expr1: [Forms]![frmMain]![Combo33] as an expression field in my query, it's a blank column.

I also just discovered that it only happens when the combo hasn't been clicked - when the first value in the list is selected by default.

DCrake
06-30-2009, 06:17 AM
Atomic Shrimp (see you got it changed) Mike. I would have thought a man with all your Access experience would have moved away from non conventional control names (Combo33).

David

Atomic Shrimp
06-30-2009, 07:21 AM
Yeah - this is the last 2 percent of development, up against a schedule and my standards have slipped a bit.

But I still can't see why it's not working. I've worked around it by putting the SQL into a string variable (with the criterion inserted in a break in the string), setting a recordset with the SQL instead of the query name - and it works, but I don't understand why.