By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Generate value in textbox based on combobox selection

P: 4
I created a product sales database which contains 4 tables. Two of those tables are Normal Transactions and Item.

Normal Transactions



I've used the Lookup function for item_ID (in the table Normal Transactions) so that it displays the values found in item_ID (of the table Item). I've also created a form for Normal Transactions.

item_ID (of the table Normal Transactions) is a combo box in the form Normal Transactions. item_cost (of the table Normal Transactions) is a text box, also in the form Normal Transactions.
How do I make it so that when I select a value from the combo box item_ID, the value of item_cost (in the Item table) which corresponds to the value of selected item_ID, is generated in the text box item_cost (in the form Normal Transactions)?
Feb 19 '10 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 3,072
Add the item_cost as third row in the rowsource for the combobox.
Next make sure that the number of columns in the Format tab is set to 3.
Finally use this line of code in the AfterUpdate event of the combobox:
Expand|Select|Wrap|Line Numbers
  1. Me.[item_cost] = Me.item_id.column(2)
The columns start at 0 so you need (2) and not (3) for the third column.

Feb 19 '10 #2

P: 4
It worked! I used (3) for the third column before, so that was the problem.
Thanks for replying, Nico!
Feb 20 '10 #3

Expert 2.5K+
P: 3,072
Glad I could teach you the "zero based" principle :-)

Feb 20 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.