combo box issues

  • Thread starter Thread starter furious_trout
  • Start date Start date
F

furious_trout

hi guys,

I have a combo box returning results from a query , but it at present when
you invoke the list it only shows the key value of the result returned
(numerical, obviously) but I want to see the name field specified in the
query. How can I specify which field from the query the combobox displays?

TIA

Dave
 
Hi

go into the properties of the combo box and you'll see the fields (use the
ALL tab)
row source
column count
column width
(and others of course)
click first in row source and then click on the ... to see the query that
the combo box is based on, ensure that the field you want to see displayed
is directly to the left of the primary key (don't delete the primary key
field) in the bottom half of the query grid
close & say Yes to update if necessary
ensure that the column count equals the number of columns in the bottom half
of the query grid
now adjust the column widths, so that the first column is 0 and the second
(the one you want to see) is the size of the combo box.

this should give you want you want.

let us know how you go

Cheers
JulieD
 
Actually if I understand you correctly, you have 2 fields for your combo. A
primary key field and a name field. When you click the combo you don't want
to see the pk field, but you still want that to be the bound field of the
combo box. If this is the case then do as Julie stated but put the pk field
first the name field to the right (second) in your query. Close and save
the query. Now set the values of the properties of the combo box to:

column count = 2
column width = 0";1.5" (not setting the first column to 0 will make it not
appear when the combo is selected
bound column = 1

Now the name field, or whatever field is your visible field will be all the
user sees, but the pk value is the value that the field(if this is a bound
control) will be set to or if not a bound control it will be the value of
the combo box. So if you selected "Smith" from the combo, and the pk field
for smith was ten(10) and you referenced the combo box

lngValue = Me.ComboBox

then lngValue would equal 10

Hope this helps.
 
Correction.
This : (not setting the first column to 0 will make it not

Wa supposed to be: (note - setting the first column to 0 will make it not
 
Right, I've got that sorted now, but the behaviour of my form seems to have
changed. Previously the query only an when the user entered the combo box,
but now it's running as soon as the form opens I'm somewhat confused!
 
Hi

must admit i don't understand this behaviour .. but you might like to take a
look at Allen Browne's code for combo boxes with large recordsets ... this
might be a possible solution to your problem.

http://members.iinet.net.au/~allenbrowne/ser-32.html

Oh the other hand, if you've only got a relative small recordset being
returned from the query and the db isn't that large i'ld be happy to take a
look at it if you want to compact / zip & email it direct to me at julied_ng
at hcts dot net dot au

Cheers
JulieD
 
Back
Top