How would I use the following statement to fill a textbox on a form with the result. The form is "switchboard" and the textbox is "text1"
SQL = "SELECT Sum(IIf(([cl]<>'y'),1,0)) FROM master;"
open your form in design view
copy everything to the right of the = in the control source for the text box to the clipboard
open the code module window
in the immediate window type ?<ctl>V this should put a ? plus what you copied to the clipboard. Press ENTER.
What error message do you get.
The reason I'm asking you to do this is because I've used DSum and DLookup hundreds of times and it's usually the criteria that bites you in the behind. The error message you get here should indicate the problem.
Out of curiosity, is the [cl] field a Yes/No field? If so you should try
=DSum("[cl]","master","[cl]=0" JHall
You can't use DSum in this case because [cl] is a text field. Try using DCount instead since a count of the records that meet your criteria is all you are really looking for.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.