Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FILL TEXTBOX WITH SQL RESULT

Status
Not open for further replies.

laman

Technical User
Jan 24, 2002
44
0
0
US
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 = &quot;SELECT Sum(IIf(([cl]<>'y'),1,0)) FROM master;&quot;

Thanks
 
in the control source of the text box try
=DSum(&quot;[cl]&quot;,&quot;master&quot;,&quot;[cl]<>'y'&quot;) JHall
 
I GET #ERROR in the textbox.
 
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(&quot;[cl]&quot;,&quot;master&quot;,&quot;[cl]=0&quot;) JHall
 
Hi!

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.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top