SQL statement on form?

  • Thread starter Thread starter matt
  • Start date Start date
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.
 
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 ...
 
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])
 
Thanks for the advice. I tried =DCount("lngID","tblTable", "CustomerID=" &
[CustomerID]) ...replacing "Table" with my table name, but I'm getting
#Error in the text box. I believe the form the control resides on is a
recordset, but how can I be sure? If it is, do I add the above expression to
the Form_Current property in VB?

Thanks again

Dirk Goldgar said:
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])

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top