Display conditional data in text box

Ringers

Registered User.
Local time
Today, 15:32
Joined
Mar 4, 2003
Messages
54
I am attempting to have a contact name displayed in text box Branch_Contact. But the result depends on the selection made in the two previous combo boxes cboBranch_Name and cboBranch_City.

I have made a Query(branch Query) that displays the contact name when run by it self, but when inserted in the control source field for the text box it doesn't work. The query code is as follows:

Select branch_contact,branch_name,branch_city
from branch
group by branch_contact,branch_name,branch_city

Branch_name
criteria: [forms]![mainform]![cbobranch_name]
Branch_city
criteria:[forms]![mainform]![cbobranch_name]

Am i even on the right track? is there an easier way to do this?
You can tell i don't have a lot of experience with this, so any assistance would be great.



:)
 
You're on the right track. The only problem is that you can't assign a query to be the recordsource of a text field on a form. A query returns a recordset, not a value that can be placed into a text box.

You have two choices: (1) do a little VB programming, open the query as a recordset, then assign the value that is returned by the recordset to the textbox. Really, it's not as scary as it sounds. (2) Use the DLookup function to pull the value from the query.

Let us know which you prefer, and we can help you along.
 
I would be happy to learn the VB code, i have done java programming, but never learnt VB.
 

Users who are viewing this thread

Back
Top Bottom