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

How to populate a text field from the combo selection

P: n/a
I am trying to populate a text field from the combo selection.

I have the following update event in the combo box
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboContract_AfterUpdate()
  2. Me!txtDesc = Me!cboContract.Column(1)
  3. Me!txtPrinc = Me!cboContract.Column(2)
  4. Me.Refresh
  5. Me.tbl_TimeData.Form.cboAct.Requery
  6. End Sub
  7.  
No errors are encountered. The text field simply does not populate for the following line of code.
Expand|Select|Wrap|Line Numbers
  1. Me!txtPrinc = Me!cboContract.Column(2)
  2.  
.

Please note that ROW SOURCE query that is applicable to the combo box
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_Contract.Contract, tbl_Contract.[Contract Description], tbl_Contract.Client_id FROM tbl_Client INNER JOIN tbl_Contract ON tbl_Client.ID=tbl_Contract.Client_id; 
  2.  
I find it strange that the [Client_id] field does not populate the [txtPrinc] field. Help appreciated
Oct 29 '10 #1
Share this Question
Share on Google+
4 Replies


100+
P: 332
Did you check with Debug.Print Me!cboContract.Column(2)
to make sure there is indeed something in Column(2)
Oct 29 '10 #2

NeoPa
Expert Mod 15k+
P: 31,419
My only guess (as it seems fine to me) is that the txtPrinc control may be misspelled.
Oct 29 '10 #3

P: n/a
Hi,

Do you mean Me!txtPrinc = Debug.PrintMe!cboContract.Column(2)? If so, I receive a syntax error in VBA screen.

The [txtPrinc] field is spelled correctly.

Any other suggestions?
Oct 31 '10 #4

100+
P: 332
No. Put it either after or before Me!txtPrinc = Me!cboContract.Column(2)
Debug.Print will output on the immediate window the value of your combo box. Ctrl+G will open the immediate window if you never used it.
Nov 1 '10 #5

Post your reply

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