SELECT statement

  • Thread starter Thread starter Hanksor
  • Start date Start date
H

Hanksor

Is it possible to use the SQL SELECT statement in a report? Here is the
statement I am using that doesn't work at this time;

SELECT tblAcctInfo.AcctName WHERE tblAcctInfo.AcctID = AcctID;

this is the control source for a text box named Text31.
I am trying to create a report that immediately takes info from a form. My
combo box on the form is associated with AcctID. I need to add the City,
State, and Zip on the report associated with the AcctID from the form. I
hope this is clear.

Any help will be appreciated.
 
You can't set the control source of a text box to the result of an sql
query.
You can use the Domain functions (DLookup etc.)

Using DLookup is probably not the best method to do this. You should build
your report on a query that has all the information in it and is filtered
based on information on the form.

Example of DLookup
=DLookup("AcctName","tblAcctInfo","AcctID= """ &
Forms!YourFormName!YourControlName & """")
If your AcctID is a number field, then you don't need the extra quotes
=DLookup("AcctName","tblAcctInfo","AcctID= " &
Forms!YourFormName!YourControlName)
 
Back
Top