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

Set the TEXTBOX value from table when select value from combobox

100+
P: 101
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.

Means whenever we select an item from combobox then automatically value of textbox set to some value from table based on query which is related to the item selected from combobox..
example
i have a table customer

CID CNAME CSALARY
1 Billa $5500
2 John $5000
3 claudia $3000
4 Yomi $5500

Now i have one form in which i have one combobox(cmbCID) and two textboxes(txtCNAME,txtCSALARY).
When i am selecting cmbCID=3 then txtcname=claudia and txtcsalary=3000 must be set in textboxes.

anyone have solution to this question?

Thanks
Dec 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: 8
billa856;

First, make sure the form's datasource is the customer table. Then, set up the combo box on your form. Might be easiest to use the combo wizard giving you the choices of which field(s) to show and which field to store as the bound column. You can, however, set up the combo box yourself putting in the properties that define the above.

You can show CID (usually not shown), CNAME &/or CSALARY as you choose in the combo box.

Then when you use the combo box and make your choice, it will automatically populate the two text boxes you've set up on the form, txtCNAME & txtCSALARY with the related fields from the chosen record.

Hope this helps,
Fresco
Dec 3 '07 #2

100+
P: 101
First, make sure the form's datasource is the customer table.

You mean to say racord source field in property.
I set the query "select * from customer;"

Then, set up the combo box on your form. Might be easiest to use the combo wizard giving you the choices of which field(s) to show and which field to store as the bound column. You can, however, set up the combo box yourself putting in the properties that define the above.

You can show CID (usually not shown), CNAME &/or CSALARY as you choose in the combo box.
Then when you use the combo box and make your choice, it will automatically populate the two text boxes you've set up on the form, txtCNAME & txtCSALARY with the related fields from the chosen record.


I can't understand above line.
Dec 4 '07 #3

P: 8
billa856:

Yes, record source was the correct name of the property I was referring to.

What are you trying to do? Select a particular customer record and associate it with other information in a new table? An example of this might be a second table to track the dates when the selected customer gave you an order.

Or, if all you want to do is look at the name and salary for a particular customer ID, you can do that by placing a WHERE clause in your Select Query for the CID field. Then the query will prompt for the ID # for you to put in. The query will then show the CNAME & CSALARY associated with that particular ID #. In this case, the parameter request is triggered when you open the form and the CID need only be a text box, not a combo box.

Add: WHERE (((tblCustomer.ID) Like [Select ID])); to the end of your Query.

To go any further, I'd need more info on your goal.

Fresco
Dec 4 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
In the After Update event of the combobox put the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbCID_AfterUpdate()
  2.  
  3.     Me!txtCNAME = Me!cmbCID.Column(1)
  4.     Me!txtCSALARY = Me!cmbCID.Column(2)
  5.  
  6. End Sub
  7.  
Does that give you the solution you need ?
Dec 11 '07 #5

Post your reply

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