Form control value update via SQL quick 'n' easy statement help...

B

blfreei

Greetings.

I'll keep my question short. I can do the following...
Me!lstDisplayInvoices.RowSource = "SELECT [qryInvoice
Display].InvoiceNumber, [qryInvoice Display].DateScanned FROM
[qryInvoice Display];"

What is a quick and easy method of performing the line below...
Me!CustomerName.Value = "SELECT tblCustomers.CustomerName FROM
tblCustomers WHERE tblCustomers!CustomerNumber = Me!CustomerNumber;"

Obviously it posts the quoted text to the form instead of executing the
query. Said query should only return 1 result, and if it doesn't I
only really care about the first result.

Thanks!

-- John
 
J

John Vinson

Greetings.

I'll keep my question short. I can do the following...
Me!lstDisplayInvoices.RowSource = "SELECT [qryInvoice
Display].InvoiceNumber, [qryInvoice Display].DateScanned FROM
[qryInvoice Display];"

What is a quick and easy method of performing the line below...
Me!CustomerName.Value = "SELECT tblCustomers.CustomerName FROM
tblCustomers WHERE tblCustomers!CustomerNumber = Me!CustomerNumber;"

Obviously it posts the quoted text to the form instead of executing the
query. Said query should only return 1 result, and if it doesn't I
only really care about the first result.

Thanks!

-- John

This seems a thoroughly roundabout way to do this. Why not just set
the ControlSource of the CustomerName textbox to

=DLookUp("[CustomerName]", "tblCustomers", "[CustomerNumbre] = " &
[CustomerNumber])

You certainly shouldn't be storing the custoemr name redundantly in
any case!

John W. Vinson[MVP]
 
Top