.column() and dlookup

chappy68

Registered User.
Local time
Today, 09:03
Joined
Aug 15, 2011
Messages
76
I have a combo box bound to an ID# and then there is a 2nd column with a description. I have a dlookup that I would like to have the description sent back to me instead of the ID# in my text box. The statement is below:

If Me.cboCategory.Value = 2 Then
Me.txtDatePerClientInfo = DLookup("ClientYrEndMo", "tblClientInfo", _
"[ClientNum]='" & Me.cboAcctNumber & "'")
'Make txtDatePerClientInfo and lblFromClientInfo visible again
Me.txtDatePerClientInfo.Visible = True
Me.lblFromClientInfo.Visible = True
End If

The IF statement is working but the value returned in txtDatePerClientInfo is the ID#, not the description as I would like. I have seen .column(1) in a few other posts but haven't been able to determine where to place it or how the logic works yet. The combo box the ID# is in is "ClientYrEndMo". I tried the .column(1) after "ClientYrEndMo" but it didn't work.

Any ideas would be appreciated.
 
Given that the description already forms part of the Row Source of your Combo, you could simply but an unbound Text Box on the form, with the following as it's Control Source;
Code:
=Combo.Column([B][COLOR="Red"]x[/COLOR][/B])
Where x represents the column number that hold the data you wish to display. Remember that the columns in a Combo or Listbox are numbered from Zero up.
 
Thanks for the suggestion. I am not sure it would have worked on my form since my form was bound to a different table and I needed the answer to be based on an entry in the current form.

I probably took the hard way and not the best way programmatically but I created another text box and did another dlookup based on text box that displayed the ID number. It works and that is all I am concerned about. Can't imagine there will be consequences except if a REAL programmer takes a look at my code and wonders what the heck I am doing.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom