473,378 Members | 1,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Generate value in textbox based on combobox selection

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

Normal Transactions
normal_trans_ID
item_ID
item_qty
item_cost
total_cost
item_date
staff_ID

Item

item_ID
item_name
item_cost

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
3 7407
nico5038
3,080 Expert 2GB
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)
  2.  
The columns start at 0 so you need (2) and not (3) for the third column.

Nic;o)
Feb 19 '10 #2
extrym
4
It worked! I used (3) for the third column before, so that was the problem.
Thanks for replying, Nico!
Feb 20 '10 #3
nico5038
3,080 Expert 2GB
Glad I could teach you the "zero based" principle :-)

Nic;o)
Feb 20 '10 #4

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

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
13
by: Paul Slavin | last post by:
I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this?? any answers appreciated, as to due to the underlying...
0
by: zhuang | last post by:
Hi, Adding combobox to datagrid has been posted many times. I have a datagrid which has multiple combobox columns and normal textbox columns. But how could I change other combo box values at...
6
by: Scotty | last post by:
Hi, I need some info How to return the value from the database My combobox Me.cboTypeAdres.Items.Add("Type Adres") Me.cboTypeAdres.Items.Add("Leverancier")...
7
by: grummanf6f | last post by:
Hello Gurus, this probably is real simple for you but for me it's a bummer. I have one table in which I have basic data collected of schools. I have another data that is detailed info on the...
4
gcoaster
by: gcoaster | last post by:
Hello! I have a dilemma I have a form that is bound to a table = tblCALLDETAILS I have a field in the table that is on the the form called = email, that is a textbox txtClientEmail ...
1
by: billypit | last post by:
Hi, I am totaly new to MS Access. I have one form in MS Access in which i want that whenever i select an item from combobox then in the textbox on the same form or subform i want value from table...
4
by: billa856 | last post by:
Hi, I want to know how can we set the value of Textbox = value of field in table when we select a value form combobx. example i have a table customer CID CNAME CSALARY 1 Billa ...
5
by: jmDesktop | last post by:
I know this should be straight forward, but I have not gotten it yet. I have a combobox and a textbox. I want to display what is selected in the combobox in the textbox. I have: ...
1
Plater
by: Plater | last post by:
I feel like this question has been asked before, but I couldn't find it. I think I am missing something obvious. Basically I am going to have a DataGridView with two columns. One textbox, one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.