Setting the Control source of a textbox to a query based on the valueof another textbox on the same

  • Thread starter Thread starter Joey
  • Start date Start date
J

Joey

Hello all,

I'm trying to set up a text box so that it displays the full name of a
customer based on the CustomerID of another text box on the same form.
The form is bound to a different table which contains the CustomerID. I
would like to set the Control source of a Fullname textbox to something
like this:

SELECT [Table1].[FirstName] & " " & [Table1].[LastName]
FROM Table1
WHERE [Table1].[lng_Customer_id] = [Forms]![frm1].[txtCustomerID]

How do I do this? Is there something wrong with using the textbox type
for a comparison with a Long data type? Is DAO my only option? It
seems there should be a much simpler solution.

Thanks
Joey.
 
Joey said:
I'm trying to set up a text box so that it displays the full name of a
customer based on the CustomerID of another text box on the same form.
The form is bound to a different table which contains the CustomerID. I
would like to set the Control source of a Fullname textbox to something
like this:

SELECT [Table1].[FirstName] & " " & [Table1].[LastName]
FROM Table1
WHERE [Table1].[lng_Customer_id] = [Forms]![frm1].[txtCustomerID]

How do I do this? Is there something wrong with using the textbox type
for a comparison with a Long data type? Is DAO my only option? It
seems there should be a much simpler solution.


Actually, you can't use an SQL statement in a control source
expression.

Try using the DLookup function instead:

=DLookup("FirstName & ' ' & LastName", "Table1",
"lng_Customer_id] = " & txtCustomerID)
 
Back
Top