SQL statement on form?

M

matt

Can someone tell me how to "attach" an SQL statement to a text box control
on a form? I have a statement that I hope returns the number of records from
a table based on the current Customer ID. Thanks in advance for any help.
 
S

Scott McDaniel

If you are using one of the Domain functions (DLookup, DMax, etc), then just
set the Controlsource of your control to that:

=DCount("lngID","tblTable")

If you're opening a recordset, then you could set this on the Current event
of the form ...
 
D

Dirk Goldgar

Scott McDaniel said:
If you are using one of the Domain functions (DLookup, DMax, etc),
then just set the Controlsource of your control to that:

=DCount("lngID","tblTable")

If you're opening a recordset, then you could set this on the Current
event of the form ...

I think, based on the reference to the "current Customer ID", that the
DCount expression might have to also apply that as a criterion.
Something like:

=DCount("lngID","tblTable", "CustomerID=" & [CustomerID])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top