var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: using combo boxes as a parameter for a query
I have created an unbound form, added a combo box and command button which will run the query. Then I have opened my query and built my expression, however, when I run execute the command button on the form I get no results. However when I run the query outside of the form I get results. I am trying to allow a user to make a selection from a combo box instead of typing in a value.
if the query's criteria is based on the value of the combobox - more than likely it is using the valu of the bound column.
The bound column (usually not visible to the user) is generally the ID for the text (description) column of the recordset
if the query is referencing the form as
forms!myform!mycombobox it is probably getting the ID valu (1 or 2 in this case) and not the text values
Just a guess based on what you posted.
format tab on the property sheet of the combobox
look for boundcolumn line change to column 2 - if in fact this is the problem
Does this sound like it is?
you can test this by placing the following code behind the afterupdate event of the combobox
msgbox comboboxName (whatever the name of the combobox is)
then select a different valu in form view and see what is displayed.
If it is a numeric value it is probably the id
I can now select a value from the combo box and get results. However if I try to select a different value I am not able to.
results such as what and behind what events?
I have a combo box that lists the different departments. What I am actuallywanting to do is produce a report from a query, however I want the user to be able to select a specific department. When I select the department and get the results, I am not able to select another department for that particular department. I am not sure what you are referring to when you speak of events.
so you are saying that after selecting say "Dept1" and the query runs
you cannot go back to the form and select another dept (Dept2) from the list and run the query?
Keep the msgbox code (msgbox comboxname) behind the afterupdate event of the combobox and see what value is displayed after each selection
if the value changes as you select different items then the problem may be in the query or how you call the query
What is the best way to set up a combo box with value to can be selected when running a report? I may be doing it the wrong way?
if the criteria for the report is based on a value from the combobox
go to the report in design mode
show the property sheet
select the data tab
go to recordsource
click the 3 button (ellipse) to the right
in the design grid of that query go to the column that represents the criteria that is needed from the combobox
on the criteria line for that field (column) place the following
where formName = the name of the form - If it is more than One word seperated by spaces place the name in Brackets
[My Form name]
same goes for the combobox name
I tried this and when I ran my report it returned no records.
you may be viewing the text value of that combo bos but it may be bound to the id field which 9 times out of ten will be a numeric value
goto the design of the combobox and go to the data tab of property sheet
change bound column from 1 to 2
If this is all the box is for - it will not have any negative affect in the code
then run the query
This did not help. What I am trying to do is. I have created a query and am trying to run a report, however, I would like to select the values from a combo box whenever I run my report.
Thanks for any help.
select a value from the combobox
now hardcode that valu in the query
change the criteria in the query from the hard value to
select from the combobox the same value you used for the hardcoded criteria
where formname is the name of the form
comboboxname is the name of the combobox
if no records - then the you are not referencing the name of the combobox or the bound coulmn for the combobox is not the same as that which is being displayed
This is all new to me so please bear with me. What do you mean by hardcode?