Unable to display values in ComboBox using SQL query from table

G

Gurvinder

I am trying to get 2 comboboxes working by using values from a single
table each combobox using one field each.

SQL Query which shows up fine in datasheet view but nothing shows up
in Form Combobox for either one.
<snip>
SELECT DISTINCT Source.dr FROM Source ORDER BY Source.dr;
</snip>

Once I get it working I would like to restrict the second combobox
using values picked from first one.

This is similar kind of code I have found examples of listed below.
Would this work.
<snip>
' ***** Code Start *****
Private Sub cboPersonID_AfterUpdate()
Me.txtPersonName.Value = Me.cboPersonID.Column(1)
End Sub
' ***** Code End *****
</snip>

Thanks,
Gurvinder Singh
 
J

Jeanette Cunningham

Hi Gurvinder,
the second combo is not needed.
If you want to show the name, you can add an unbound textbox to the form.
Set its control source to
=Me.NameOfFirstCombo.Column(1)

After you choose a value from the 1st combo, the person's name will show up
in the unbound textbox.

Replace the obvious with the name of the combo.
Column(1) is the second column in the combo.
If the query for the combo has more than 2 columns, then change the (1)
after column to get the correct column with the person's name.
Combo columns are numbered with the first column having number zero.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
G

Gurvinder

Thanks a bunch Jeanette :)

Gurvinder

Hi Gurvinder,
the second combo is not needed.
If you want to show the name, you can add an unbound textbox to the form.
Set its control source to
=Me.NameOfFirstCombo.Column(1)

After you choose a value from the 1st combo, the person's name will show up
in the unbound textbox.

Replace the obvious with the name of the combo.
Column(1) is the second column in the combo.
If the query for the combo has more than 2 columns, then change the (1)
after column to get the correct column with the person's name.
Combo columns are numbered with the first column having number zero.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia










- Show quoted text -
 

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