combodifficulties

I

IRene

1) I've created a combobox that takes data from a table.
And I used the Distinct function to filter out the
repeated values in the table. However,when I click on my
combobox and select a value, let's say 4000, the number
that shows after I click on the value is 20; 20 is the
very first number that appears in line in the combobox.
How do I correct this?

SELECT DISTINCT [tblName].[HIDDEN FIELD], [tblName].
[NameofFieldThat is Relevant for me] FROM [tblName];

2) In addition, I created combobox2 that takes data from a
table (its values are unique). And I wrote a code so that
the values shown will only be those related to values in
combobox1. That way, instead of a list of 80 text shown
in combobox2, it should be just about 5 or so. However, m
y code does not work. Now values appear in my combobox.
Here is the code:

SELECT [tblName].[HiddenFieldForSomeReasonIs Listed],
[tblName].[RelevantField2] FROM [tblName] WHERE
[RelevantFieldFromCombobox1]=[Forms]![frmName]!
[Combo2].Value;


Irene
 
K

Ken Snell

1.
Likely you need to change the properties that you have set for the combo
box. If you want to hide the first column, then do the following (based on
your row source query):

Open the form in design view. Click on the combo box. Open the Properties
window (icon on toolbar). Click on Format tab. Change Column Count to 2.
Change Column Widths to 0";1".

2.
Requery the second combo box in the AfterUpdate event of the first combo
box:
Private Sub ComboBox1_AfterUpdate()
Me.ComboBox2.Requery
End Sub
 

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