Dcount in a Form

Coldsteel

Registered User.
Local time
Today, 09:40
Joined
Feb 23, 2009
Messages
73
I have a form called Totals which has 2 text boxes.
One you enter a ID number. The textbox is called txtPS.
The other has my Dcount code. Called txttotals.

Code:
=DCount("[APPROVED]","tbl_sales","Seller =" & Forms!QuickStats!txtSeller And [APPROVED]="Approved" And [DATE REFERRED] Between DateSerial(Year(Date()),Month(Date()),1) And Now())


My code is not working I keep getting #Name?, any help would be greatly appreciated
 
You did not restart your string after the form reference, and you'll need to use single quotes around Approved (because you'll have all that inside double quotes, and those would confuse the issue).
 
Sorry I am new to using the Dcount funcation, is this what you mean?

Code:

=DCount("[APPROVED]","tbl_sales","Seller =" & Forms!QuickStats!txtSeller And [APPROVED]='Approved' And [DATE REFERRED] Between DateSerial(Year(Date()),Month(Date()),1) And Now())
 
=DCount("[APPROVED]","tbl_sales","Seller =" & Forms!QuickStats!txtSeller & " And [APPROVED]='Approved' And [DATE REFERRED] Between " & DateSerial(Year(Date()),Month(Date()),1) & " And " & Date())

And if Seller is text then it would need to be:

=DCount("[APPROVED]","tbl_sales","Seller ='" & Forms!QuickStats!txtSeller & "' And [APPROVED]='Approved' And [DATE REFERRED] Between " & DateSerial(Year(Date()),Month(Date()),1) & " And " & Date())
 
Last edited:
And actually with the dates you might need:

=DCount("[APPROVED]","tbl_sales","Seller ='" & Forms!QuickStats!txtSeller & "' And [APPROVED]='Approved' And [DATE REFERRED] Between #" & DateSerial(Year(Date()),Month(Date()),1) & "# And #" & Date() & "#" )
 
If you're going to jump in, at least post correct code, eh? ;)

(misplaced #)
 
If you're going to jump in, at least post correct code, eh? ;)

(misplaced #)
Can't tell if that is a friendly snipe or an angry one (and I fixed the location - it jumped on me just before I hit the post button - dang code I hate it when it doesn't cooperate :) )
 
Friendly; that's why I included the Canadian "eh" for you. :p
 
Friendly; that's why I included the Canadian "eh" for you. :p
I rarely can tell what most of those darn smileys are doing. There are a few that are hard to miss but a few that are just plain confusing.
 
Thanks for helping me out. I have been trying to implement this and I am getting a #error. I don’t know what I am doing wrong
 
I figured out what I was doing wrong, I pasted the code incorrectly. Here is what worked for me

=DCount("[APPROVED]"," tbl_sales ","[Seller]=" & Forms!QuickStats!txtSeller & " And [APPROVED]='Approved' And [DATE REFERRED] Between #" & DateSerial(Year(Date()),Month(Date()),1) & "# And #" & Date() & "# ")

Thank you guys for all the help!!!!!
 

Users who are viewing this thread

Back
Top Bottom