By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,393 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,393 IT Pros & Developers. It's quick & easy.

Problem Setting Combobox Choices from Stored Query

P: n/a
I have a form with several comboboxes whose contents I'm trying to
initialize from a table. The table, ComboSelections, has 3 fields,
an autonumber ID and two text fields, ListCode and ListEntry. ListCode
contains the actual names of the comboboxes, each of which has several
ListEntry values. Here for example is the part of the table that
'defines' the cboQuality_rating combobox:

Id ListCode ListEntry
1 cboQuality_rating Excellent
4 cboQuality_rating Adequate
5 cboQuality_rating Fair
6 cboQuality_rating Limited
7 cboQuality_rating Poor

I've created a single stored query for the row source of each of these
comboboxes:
---------------------------
SELECT ComboSelections.ListEntry
FROM ComboSelections
WHERE (((ComboSelections.ListCode)=[forms]![datasystem]![thisList]));

thisList is a global variable in form datasystem [I note now that in the
way I was hoping to do this, a local variable in the onload sub of the
function should be sufficient].

If I try to use Me!thisList in the WHERE clause above, it gets
interpreted as a parameter: this, too I don't understand.

Then I try to use this scheme: I will fill the comboboxes when loading
the form:

Private Sub Form_Load()
thisList = cboQuality_rating.Name
cboQuality_rating.Requery
Debug.Print "LOADING FORM: thisList = *" & thisList & "*"

End Sub

In the immediate window I do get LOADING FORM: thisList = *cboQuality_rating*
But nothing gets loaded into the combobox. What am I doing wrong?

thanks, --thelma
Dec 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thelma Roslyn Lubkin wrote:
I have a form with several comboboxes whose contents I'm trying to
initialize from a table. The table, ComboSelections, has 3 fields,
an autonumber ID and two text fields, ListCode and ListEntry. ListCode
contains the actual names of the comboboxes, each of which has several
ListEntry values. Here for example is the part of the table that
'defines' the cboQuality_rating combobox:

Id ListCode ListEntry
1 cboQuality_rating Excellent
4 cboQuality_rating Adequate
5 cboQuality_rating Fair
6 cboQuality_rating Limited
7 cboQuality_rating Poor

I've created a single stored query for the row source of each of these
comboboxes:
---------------------------
SELECT ComboSelections.ListEntry
FROM ComboSelections
WHERE (((ComboSelections.ListCode)=[forms]![datasystem]![thisList]));

thisList is a global variable in form datasystem [I note now that in the
way I was hoping to do this, a local variable in the onload sub of the
function should be sufficient].

If I try to use Me!thisList in the WHERE clause above, it gets
interpreted as a parameter: this, too I don't understand.

Then I try to use this scheme: I will fill the comboboxes when loading
the form:

Private Sub Form_Load()
thisList = cboQuality_rating.Name
cboQuality_rating.Requery
Debug.Print "LOADING FORM: thisList = *" & thisList & "*"

End Sub

In the immediate window I do get LOADING FORM: thisList = *cboQuality_rating*
But nothing gets loaded into the combobox. What am I doing wrong?

thanks, --thelma
There is a difference between a variable and a text box. You assign a
global variable a value. But you have a query referencing (most likely
a textbox) an object [forms]![datasystem]![thisList].

It won't work. I would consider creating a text box, setting the
visible property to False/No, and assign your value to the textbox.

That Girl
http://www.youtube.com/watch?v=tBe4W-j6UO8
Dec 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.