Problem with populating field

Z

Zaz

I've been attempting to populate a field based on what is selected in another combo box. What is happening is I select an item in the combo box and it doesn't update the other field. I've tried several methods while looking through the posts here including Me.Requery and I just can't get it to work. I have a table with the following fields "Sublot" and "QtyOnHand" among others. I tried creating the form by accessing the table directly and setting up a query. If someone could sort of walk me through how exactly to select a "Sublot" from a combo box and have it update the "QtyOnHand" field, it would be greatly appreciated...

Thanks
 
N

Nikos Yannacopoulos

Zaz,

One way to do it is have the Before Update event of the combo fire a macro
with a SetValue action. The arguments to the action should be:
Item: the name of the target text box
Expression:
DLookup("[QtyOnHand]","YourTableName","[Sublot]=Forms![YourFormName]![ComboN
ame]")

HTH,
Nikos

Zaz said:
I've been attempting to populate a field based on what is selected in
another combo box. What is happening is I select an item in the combo box
and it doesn't update the other field. I've tried several methods while
looking through the posts here including Me.Requery and I just can't get it
to work. I have a table with the following fields "Sublot" and "QtyOnHand"
among others. I tried creating the form by accessing the table directly and
setting up a query. If someone could sort of walk me through how exactly to
select a "Sublot" from a combo box and have it update the "QtyOnHand" field,
it would be greatly appreciated...
 
N

Nikos Yannacopoulos

You could use code instead, which I would actually prefer, but your question
is a very common one in these newsgroups, and in my experience users who ask
it don't feel comfortable with code. Would you want to give it a shot? The
concept is the same, the code would be something like:

Me.TargetTextBoxName = DLookup("[QtyOnHand]","YourTableName","[Sublot]=" &
Me.ComboName)
if Sublot is numeric, or
Me.TargetTextBoxName = DLookup("[QtyOnHand]","YourTableName","[Sublot]='" &
Me.ComboName & "'")
if it is text.

Nikos

Zaz said:
Thanks. I can try that. Is there a way of doing it without the Macro?


Nikos Yannacopoulos said:
Zaz,

One way to do it is have the Before Update event of the combo fire a macro
with a SetValue action. The arguments to the action should be:
Item: the name of the target text box
Expression:
DLookup("[QtyOnHand]","YourTableName","[Sublot]=Forms![YourFormName]![ComboN
ame]")

HTH,
Nikos
 

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