I'm trying to use combo boxes to select info to be shown in a text

P

pjluckyman

I'm trying to use a group of combo boxes to select a count of a query in a
form or report.

Currently I have three variables on the form I want to use and have a text
box show the counts of instances within a particular query.

=DCount("[MXGPC-WKCTR STRIPPED] & [DAFSC] &
[ACT-GR]","qry4monthprojectionloss","[MXGPC-WKCTR STRIPPED] =
'rptfrm.form![1st Workcenter]' and [ DAFSC]='rptfrm.form![1st DAFSC]' and
[ACT-GR]= 'rptfrm.form![ACT-GR1]'")



If I replace the form refrences (rptfrm.fomr![1st Workcenter]) with specific
criteria (AMXS) it will do the count and display the number of occurances.
What am I doing wrong in my expression that it will not use the comboboxes?
I'm not worried about the names of the combo boxes if I need to change them
Help......
 
J

John W. Vinson

If I replace the form refrences (rptfrm.fomr![1st Workcenter]) with specific
criteria (AMXS) it will do the count and display the number of occurances.
What am I doing wrong in my expression that it will not use the comboboxes?
I'm not worried about the names of the combo boxes if I need to change them
Help......

You're searching for records where the text field contains the *NAME* of the
combo box (by enclosing the name in quote marks). Instead you want to
concatenate the *value* of the textbox.

In addition, with DCount, you are actually counting the number of records
which meet the criteria. You don't need to construct the concatenation in the
first argument - I'm not sure what you're trying to accomplish by doing so in
fact! Also, your syntax for the forms reference is incorrect.

Try

=DCount("*","qry4monthprojectionloss","[MXGPC-WKCTR STRIPPED] = '" &
Forms!rptfrm![1st Workcenter] & "' and [ DAFSC]='" & Forms!rptfrm![1st DAFSC]
& "' and [ACT-GR]= '" & Forms!rptfrm![ACT-GR1] & "'")

This assumes that your three fields are all of Text datatype, and that you
have an open form named rptfrm with three controls on it with the cited
control names.
 

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