REPOST: Cmd Button Issue

J

James

I have a form where by I have 3 cboboxes on it...

These have the follwoing values:

cbo1 (Male,Female)
cbo2 (Q01,Q02....Q25)
cbo3 (True,False)

I have a query which calculates the percentage in the
database based on the values of them cboboxes.... so it
gets the percentage of the total number of records by how
many of the values in them cboboxes...

I would need my text box to pull up that percentage from
the query based on what is in the cboboxes.... So if they
change I would need the text box to be updated when all
the values have changed and maybe a calculate button
pressed? or if not then how do I do this without the
command button?

IS this possible?

Many Thanks for your time and effort

James
 
N

Nikos Yannacopoulos

James,

If your query already calculates this correctly and returns a single record
with the percentage, then:
Make the result textbox's controlsource property something like:
=DFirst("[fieldname]","queryname")
substituting with the actual query name and field name of the field
calculating the result. Then use the Before Update or On Change event of all
three combos to run the same macro, with a single action Requery on the text
box (argument: the name of the text box on the form).
This way you'll get the new result every time one of the combos is changed,
without having to add and click a separate command button. The separate
command button (which would run the same macro, instead of it being run by
the combo events) should be considered in case the table is big and the
query takes some time to run, so for example you'd want it to run only once
you've selected the values of all three combos rather than onchanging each
one.

HTH,
Nikos
 
J

James

Ok many thanks for that but when I put in the dFirst thing
in the text box I am getting #ERROR....

The Query I have for doing calculating a percentage was
given to me by someone on these newsgroups...

-----------------------------------------------------------

SELECT Count(1) AS ReturnCount, 100*Count(1)/(Select Count
(*) FROM tblResponses) AS ReturnPercentage
FROM tblResponses
WHERE ((([gender])=[Forms]![frmqry]![cboGender]) AND
(([question])=[Forms]![frmqry]![cboQuestion]) AND
((tblResponses.Answer)=[Forms]![frmqry]![cboAnswer]));

-----------------------------------------------------------

For some reason it seems to do nothing... It returns
nothing... I have test records in the tblRespionses....
What could be wrong...

tblResponses consists of the following...

ResponseID (AutoNumber)
RespondantID (Number Field) with relationship of one to
many to a tblGender. tblGender just has the values of Male
and Female. Also has a primary kay and auto number field
called GenderID... this is the link field with
tblResponses.

QuestionID (Number) with a relationship of one to many to
tblQuestion. tblQuestion just has the values of
Q01,Q02...Q25. Also has a primary kay and auto number
field called QuestionID... this is the link field with
tblResponses.

Answer (Yes/No)as a check box and is in a cboBox form in
the query form which I am running that above SQL query
from.

Does this help in assisting with the issue I have
described above?

Many Thanks

James
-----Original Message-----
James,

If your query already calculates this correctly and returns a single record
with the percentage, then:
Make the result textbox's controlsource property something like:
=DFirst("[fieldname]","queryname")
substituting with the actual query name and field name of the field
calculating the result. Then use the Before Update or On Change event of all
three combos to run the same macro, with a single action Requery on the text
box (argument: the name of the text box on the form).
This way you'll get the new result every time one of the combos is changed,
without having to add and click a separate command button. The separate
command button (which would run the same macro, instead of it being run by
the combo events) should be considered in case the table is big and the
query takes some time to run, so for example you'd want it to run only once
you've selected the values of all three combos rather than onchanging each
one.

HTH,
Nikos

I have a form where by I have 3 cboboxes on it...

These have the follwoing values:

cbo1 (Male,Female)
cbo2 (Q01,Q02....Q25)
cbo3 (True,False)

I have a query which calculates the percentage in the
database based on the values of them cboboxes.... so it
gets the percentage of the total number of records by how
many of the values in them cboboxes...

I would need my text box to pull up that percentage from
the query based on what is in the cboboxes.... So if they
change I would need the text box to be updated when all
the values have changed and maybe a calculate button
pressed? or if not then how do I do this without the
command button?

IS this possible?

Many Thanks for your time and effort

James


.
 

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

Similar Threads

REPOST: Problems with Text Box 9
Cascading Combo Boxes 2
Help with Query 4
Totals Query? 24
Creation of an Input Form 17
Cmd Button Issue 5
2 cboBox criteria in filter 3
user form, saving values 3

Top