Getting a Query to output to a textbox

Bullet

New member
Local time
Today, 22:33
Joined
Mar 2, 2009
Messages
8
Ive got a series of names in a drop down list in a form.

What think I need to do (and this is where i need help) is run a query that depending on which name has been selected from the drop down list will display the address and phone number from the original table in the text boxes.

Is this possibible??

Do I need a query to perform said action ??

Any help would be much appricated,

Kind Regards,
Bullet:rolleyes:
 
One easy way is to include the adressfield and phone in the Rowsource of your combobox and hide them by setting the coloumwidth to 0 and the you can refrence these in the afterUpdate event of your combobox.

Code:
Private Sub cbo1_AfterUpdate()
    Me.txtlookup = Me.cbo1.Column(2) & " " & Me.cbo1.Column(3)
End Sub

Just remember that the combobox is zerobased so coloum 2 in my example is really column 3

JR
 
Thanks! thats worked perfectley
 
Glad to help. One thing this only works on single forms and not continious forms.

I also forgot to tell you to add the same code to your form Current_event or else your lookuptextbox will be blank when you scroll your records.

Code:
Private Sub Form_Current()
    Me.txtlookup = Me.cbo1.Column(2) & " " & Me.cbo1.Column(3)
End Sub

JR
 
If you don't like too use VBA then you could simply set the controlSource of txtLookup to

Code:
=cbo1.column(2) & " " & cbo1.column(3)

It is usually an alternative to VBA. :cool: (not as fun but....)

JR
 

Users who are viewing this thread

Back
Top Bottom