View Full Version : Pass Date Value from Combobox


rainman89
09-28-2007, 07:16 AM
Hi all,
Dont know why im having such a hard time with this one. im trying to pass a date value from a combo to a query in my subform and failing miserably. thought it would be as simple as doing a

[forms]![frmSelecteditexpense].[cboExpensedate]

in the criteria for expensedate, but im getting no returns. what am i missing?
cbo expense date is formated as a shortdate and its values are from the expense date field itself.

Thanks in advance

RuralGuy
09-28-2007, 08:07 AM
SubForms are not listed in the Forms collection, if that helps.

boblarson
09-28-2007, 08:32 AM
Hi all,
Dont know why im having such a hard time with this one. im trying to pass a date value from a combo to a query in my subform and failing miserably. thought it would be as simple as doing a

[forms]![frmSelecteditexpense].[cboExpensedate]

in the criteria for expensedate, but im getting no returns. what am i missing?
cbo expense date is formated as a shortdate and its values are from the expense date field itself.

Thanks in advance


Ray - here's a little tip for getting the right thing into the criteria of a query when a subform is involved:

1. From the criteria, click on the builder button.

2. Navigate to the main form and then the subform and then to the control (within the builder window) and then double click on the control to add it to the builder.

It should then have the correct syntax you are looking for. If you navigate to the subform directly it won't work, but if you navigate to it via through the main form and then to the subform (that is, in the tree view in the builder, not to the form directly).

ajetrumpet
09-28-2007, 08:34 AM
Just give him the FAQ page bob.. :rolleyes:

rainman89
09-28-2007, 09:03 AM
I feel like a jackass cuz this isnt working. im sure its something small and simple..

Combo box is in the main form and i want it to drive the value of the subform. ive done it many many times..... and for some reason its not going this time.
ive changed the criteria to

me.frmselecteditexpense!cboexpensedate

and a whole bunch of other things. still confused.

boblarson
09-28-2007, 09:08 AM
I feel like a jackass cuz this isnt working. im sure its something small and simple..

Combo box is in the main form and i want it to drive the value of the subform. ive done it many many times..... and for some reason its not going this time.
ive changed the criteria to

me.frmselecteditexpense!cboexpensedate

and a whole bunch of other things. still confused.

Did you try my method of getting the syntax? If not, I would do that as it is much easier than trying to remember what it is.

However, given what you've posted, in the criteria of a query, it would be:

Forms![YourMainFormNameHere]![YourSubFormContainerNameHere].Form![cboexpensedate]

make sure that frmselectededitexpense is the subform CONTAINER name and not just the subform name.

rainman89
09-28-2007, 09:11 AM
ya i did try your syntax and it ended up giving me

forms!frmselecteditexpense.cboexpensedate

container name is the same as form name.

have naything to do with the fact that its a date?

boblarson
09-28-2007, 09:14 AM
ya i did try your syntax and it ended up giving me

forms!frmselecteditexpense.cboexpensedate



The reason it did this is you didn't navigate to it properly. You navigated to it directly instead of through the main form. I guess I'll do screenshots to show you how. I'll post back with it momentarily.

boblarson
09-28-2007, 09:21 AM
http://downloads.btlarson.com/AWF/screenshots/subforms/subformsyntaxselect01.png

http://downloads.btlarson.com/AWF/screenshots/subforms/subformsyntaxselect02.png


P.S. I did forget to tell you that you had to have the Main form opened for this to work.

rainman89
09-28-2007, 09:29 AM
ok the combobox is on the main form.

so why do i have to navigate through the mainform to the subform?

boblarson
09-28-2007, 09:38 AM
ok the combobox is on the main form.

so why do i have to navigate through the mainform to the subform?

I misunderstood. Anyway, if you wish you can send it to me and I'll see if I can figure out the problem.

rainman89
09-28-2007, 10:18 AM
Im gonna take a break from it for awhile and then maybe mess around with it a bit more. im sure im missing something very simple... ill be coming back when i get frustrated again!

Thanks boB