Combo Box selection to auto load a field and ability to detect cha

M

MSA

I have a form that has a combo box called "Product", now each product has an
associated RO#. So when a user selects a Product the related RO# should auto
fill in the second text field.

Secondly, the user may decide to change the product selection during form
entry the RO# field which is filled already based on the earlier Product
selection should be able to detect that the combo box Product has been
updated and populate itself with the relevant Ro#.

Let me, try to explain by example
I have a combo box called "Product", having the following enteries each with
a unique RO#:
Product: A Ro#: 1
B 2
C 3

Now, based on the Product selected from the above list an RO# should be
automatically loaded in the RO# field.

The other thing is that if a user decides to change the selection in Product
combo box prior to saving e.g.

User selects Prod=A
Ro# should be filled with "1"

Now the user decides to change the Product selection to: C
RO# should detect the change update accordingly by filling it with "3".

Please let me how best this can be done, thanks in advance.

Regards,
MSA
 
N

Naeem Azizian

Let say you have a FirstCombo that contains A and SecondCombo that
contains 1

Your firstcombo should have two columns. Product name and product ID.
let's think product Name is column 0 (first column) and product ID is
column 1 (second column). Your Second combo should also have two
columns, column 0 to be product ID and column 1 to be product name.

here is a bit of code you need after all. in the afterupdate event of
your FirstCombo put this:
me.secondcombo = me.firstcombo.column(1)

in the afterupdate of your secondcombo put this:
me.firstcombo = me.secondcombo.column(1)
 
M

MSA

Hi,

I tried your suggestion by putting the following in Product combo box
me.RO#=me.Product.column(1)
and
for RO#
me.Product=me.RO#.column(1)

When I tried it I get the following error message:

MS Access con't find the macro "me"

Please review and let me know where I might be going wrong, thx.

Regards,
MSA
 
R

Ron2006

The instructions that he gave you should be in the afterupdate event.

in the Properties for combobox for Product
have nothing in the row next to that but press the .... box to the
right of the column.
Select "Code"
place the following in the code window that comes up.
me.RO# = me.Product.column(1)
(assuming that the query for product is defined as Naeem
suggested.

No other code is necessary and the RO# does not have to be a combo -
at least as far as I understand your description.

Ron
 

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