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

need help with code for combo box

P: 18
hi i have a form with a combo box and two text boxes on it.
i want it set up so when a selection is made from the combo box the two text boxes will display the corresponding data from the table.

the table name is: New Plymouth
the fields included in the table: Destination
Kilometres One Way
Kilometres Return

the name of the combo box : Dest
the first text box: Kms
the 2nd text box: Kms1

the combo box displays the destinations from the table, i want the Kms text box to display the one way kms and i want the Kms1 text box to display the return kms.

i currently have the following code which works fine with one text box but i am un sure what changes are required to make it work for two text boxes.

the code is:

after update in the combo box

Private Sub Dest_AfterUpdate()
Me!Kms = Me!Dest.Column(1)
End Sub

can anyone please help me???????
May 29 '07 #1
Share this Question
Share on Google+
7 Replies

Rabbit
Expert Mod 10K+
P: 12,441
hi i have a form with a combo box and two text boxes on it.
i want it set up so when a selection is made from the combo box the two text boxes will display the corresponding data from the table.

the table name is: New Plymouth
the fields included in the table: Destination
Kilometres One Way
Kilometres Return

the name of the combo box : Dest
the first text box: Kms
the 2nd text box: Kms1

the combo box displays the destinations from the table, i want the Kms text box to display the one way kms and i want the Kms1 text box to display the return kms.

i currently have the following code which works fine with one text box but i am un sure what changes are required to make it work for two text boxes.

the code is:

after update in the combo box

Private Sub Dest_AfterUpdate()
Me!Kms = Me!Dest.Column(1)
End Sub

can anyone please help me???????
Expand|Select|Wrap|Line Numbers
  1. Private Sub Dest_AfterUpdate()
  2. Me!Kms = Me!Dest.Column(1)
  3. Me!Kms1 = Me!Dest.Column(2)
  4. End Sub
  5.  
May 30 '07 #2

P: 18
thanks for the help but i already tryed that and it didn't work i can't work out why???
May 30 '07 #3

P: 18
the statement i have in the combo box row source is as follows:
SELECT * FROM [New Plymouth] ORDER BY [New Plymouth].Destination;

is there something worng with this????

it works fine with the first text box but nothing appears in the second text box
May 30 '07 #4

Rabbit
Expert Mod 10K+
P: 12,441
the statement i have in the combo box row source is as follows:
SELECT * FROM [New Plymouth] ORDER BY [New Plymouth].Destination;

is there something worng with this????

it works fine with the first text box but nothing appears in the second text box
Interesting... it should work perfectly fine. The one time something like this happened to me was because I had overlapping names. Check all field names in the recordsource, function names in the modules, variable names, etc. and see if you've given more than one thing the same name.
May 31 '07 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Interesting... it should work perfectly fine. The one time something like this happened to me was because I had overlapping names. Check all field names in the recordsource, function names in the modules, variable names, etc. and see if you've given more than one thing the same name.
Check the Column Count property under the format tab. It should be set to at least 2 if you want to use both the first and second column
Jun 1 '07 #6

P: 18
thanks for the help it was the column count that needed changing...
THANKS EVERYONE :)
Jun 4 '07 #7

MMcCarthy
Expert Mod 10K+
P: 14,534
thanks for the help it was the column count that needed changing...
THANKS EVERYONE :)
You're welcome.

Glad you got it sorted.

Mary
Jun 5 '07 #8

Post your reply

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