Parameter from Form

M

Melinda

Hello,
I have a query that uses a parameter on my form to update a combo box.

My SQL:
SELECT DISTINCT [Phase]
FROM tblPhases
WHERE [JobCode] LIKE("*"&[Forms]![frmTimeCard]![JobCode]&"*");

Here's my problem. Using my current bit of code, I get every possible Phase
from my table, instead of the Phases that go with a particular JobCode. I
tried eliminating the "*" that are concatinated on, but then my combo box
doesn't display anything. Any ideas on how to make this work?
Thanks!
Melinda
 
O

Ofer

While the form is runing, select a value in the combo and type
?Forms![frmTimeCard]![JobCode]
In Immidiae window (Ctrl+G)

What value return?
If no value is returned, this is why you are getting all the records.

Mybe you need to filter on a different column in the combo, or mybe its the
wrong field name.
 
M

Melinda

Well, it didn't like the fact that JobCode is actually in a SubForm.
But if I try [Forms]![frmSub]![JobCode] in my query, I get a message box
that pops up asking me to fill in the parameter. Also, could it be an issue
that my combo box has 2 columns? How can a tell a query to look only at
column 1?
Thanks,
Melinda

Ofer said:
While the form is runing, select a value in the combo and type
?Forms![frmTimeCard]![JobCode]
In Immidiae window (Ctrl+G)

What value return?
If no value is returned, this is why you are getting all the records.

Mybe you need to filter on a different column in the combo, or mybe its the
wrong field name.


--
I hope that helped
Good luck


Melinda said:
Hello,
I have a query that uses a parameter on my form to update a combo box.

My SQL:
SELECT DISTINCT [Phase]
FROM tblPhases
WHERE [JobCode] LIKE("*"&[Forms]![frmTimeCard]![JobCode]&"*");

Here's my problem. Using my current bit of code, I get every possible Phase
from my table, instead of the Phases that go with a particular JobCode. I
tried eliminating the "*" that are concatinated on, but then my combo box
doesn't display anything. Any ideas on how to make this work?
Thanks!
Melinda
 
M

Melinda

It was the Subform tripping it up. It seems I needed my parameter to be:
[Forms]![frmTimeCard]![Time Sub]![JobCode]
Whew! Now I feel dumb!
Thanks,
Melinda
 
O

Ofer

To refer to a sub form, try this syntax

[Forms]![frmTimeCard]![Time Sub].form![JobCode]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top