combo boxe

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form based on a query. I was using a combo box on the form to have
the user select from the following list

code Prodname vendor rawid#

they are comfortable knowing the code to the drop down works fine. want all
3 fields to automatically get filled in on the form and to populate the
record for the underlying query. Have tried in form view to set the other 3
fields control source to =comboname.Column(#)
It works for the form and put the fields on it but does not populate the
underlying query.

The two table the query is based on it are

Raw Matl info Table
rawmatid(P)
code
prodname
vendorname
etc

Receiving
Trans#(p)
date
time
code
rawmatid


need help displaying list of code,prodname,vendor,rawmatid

bottom line want them to select the code and all other 3 fields get
populated in query and form!!

Please help,
Thanks,
Barb
 
Barb,

Using a control's ControlSoure property to make it "read" a value from a
column in a combo is the easiest way to achieve that; regrettably,
though, in life there is a price to be paid for everything, and in this
case the price for ease is not being able to store this value in a table
easily! The reason is simply that; in osrder to store the value, tho
control's ControlSource property should be set to the table field you
want to store into. To achieve what you want, you must set the
ConrtolSource property so the table field, and employ some other method
to make the control "read" the value from the combo. The way I'd
recommend is to use the On Change event of the combo to run simple lines
of code such as :

Me.Text1 = Me.Combo1.Column(#)

where, of course, you change Text1 and Combo1 to the actual names of the
controls on the form.

By the way, note that queries are just filters for data stored in
tables, they do not store data themselves; that is to say, even if a
form is based on a query, entering data populates the table(s) the query
is based on, not the query itself.

HTH,
Nikos
 
Really want the data to get back into the underlying tables - sorry that is
what I meant. Not sure if this will do that and not sure if it does if I
should list multiple line on the onchange event for each item in the combo I
want to capture???
 
Well, so long as you bind your controls to the table fields (through the
query) the values will be saved in the tables, provided the query itself
is updatable. You can verify the latter by opening the query directly,
and attempting to make a change in a field, or add a new record. If you
can do that then there is no problem, if you get an error message saying
"recordset not updatable" then you have to go a different way altogether.

As for the combo event code, you need one line for each combo column /
textbox to be set, like:

Me.Text1 = Me.Combo1.Column(1)
Me.Text2 = Me.Combo1.Column(2)
Me.Text3 = Me.Combo1.Column(3)
etc.

Hope this is clear now.

Nikos
 
I did what you said
after I select a code from the drop down list I get a run time error
(-2147352567) of current field must match join key - enter record in the one
side table with the desired key value, and then make the entry with the
desired join key in the many-only table. Not sure what is going on -
something to do with rawmatmfgid being an auto key in the one side table?????
 
Hmmm... sounds like your form is based on a non-updatable query. Did you
heck the query as per my previous post? What happened? Does your form
have a subform?

Nikos
 
Back
Top