dcount syntax

G

Greg

what's wrong with the syntax of this:

=DCount("*","tblcontactdata","[date] Between #" & [txtboxstartdate] & "# And
#" & [txtboxenddate] & "#" &
IIf(IsNull(Forms!querybuilder!cboxupsource)=True,""," And [upsource]=" &
Chr(34) & Forms!formquerybuilder!cboxupsource & Chr(34)) &
IIf(IsNull(Forms!querybuilder!cboxdepartment)=True,""," And [department]=" &
Chr(34) & Forms!formquerybuilder!cboxdepartment & Chr(34)))

formquerybuilder is a form that creates the report that this dcount is a
part of. tblcontactdata is not the recordsource of that report. upsource,
department are both text. date is a date format. i have been playing with
this for a while and now i've got it to the point where i get a name error.
any thoughts? thanks.
 
D

Douglas J. Steele

Nothing jumps out as obviously wrong.

Are you getting an error message? If so, what is it? If you're not getting
an error message, what's happening?
 
G

Greg

i get a name error.
--
Greg D.


Douglas J. Steele said:
Nothing jumps out as obviously wrong.

Are you getting an error message? If so, what is it? If you're not getting
an error message, what's happening?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Greg said:
what's wrong with the syntax of this:

=DCount("*","tblcontactdata","[date] Between #" & [txtboxstartdate] & "#
And
#" & [txtboxenddate] & "#" &
IIf(IsNull(Forms!querybuilder!cboxupsource)=True,""," And [upsource]=" &
Chr(34) & Forms!formquerybuilder!cboxupsource & Chr(34)) &
IIf(IsNull(Forms!querybuilder!cboxdepartment)=True,""," And [department]="
&
Chr(34) & Forms!formquerybuilder!cboxdepartment & Chr(34)))

formquerybuilder is a form that creates the report that this dcount is a
part of. tblcontactdata is not the recordsource of that report.
upsource,
department are both text. date is a date format. i have been playing with
this for a while and now i've got it to the point where i get a name
error.
any thoughts? thanks.
 
D

Douglas J Steele

Unfortunately, "name error" doesn't tell me anything. What's the exact text
of the error message? And when does it occur: when your code is running, or
when you try to compile the code? Does it matter whether or not there's
something selected in the comboboxes?

What are [txtboxstartdate] and [txtboxenddate]? If they're textboxes on your
form, you should refer them the same way you're referring to the comboboxes.

You're sure that upsource and department are the correct fields in
tblcontactdata, and that cboxupsource and cboxdepartment are the correct
name for the comboboxes on formquerybuilder?

BTW, you'd be better off renaming your field date in tblcontactdata.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Greg said:
i get a name error.
--
Greg D.


Douglas J. Steele said:
Nothing jumps out as obviously wrong.

Are you getting an error message? If so, what is it? If you're not getting
an error message, what's happening?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Greg said:
what's wrong with the syntax of this:

=DCount("*","tblcontactdata","[date] Between #" & [txtboxstartdate] & "#
And
#" & [txtboxenddate] & "#" &
IIf(IsNull(Forms!querybuilder!cboxupsource)=True,""," And [upsource]=" &
Chr(34) & Forms!formquerybuilder!cboxupsource & Chr(34)) &
IIf(IsNull(Forms!querybuilder!cboxdepartment)=True,""," And [department]="
&
Chr(34) & Forms!formquerybuilder!cboxdepartment & Chr(34)))

formquerybuilder is a form that creates the report that this dcount is a
part of. tblcontactdata is not the recordsource of that report.
upsource,
department are both text. date is a date format. i have been playing with
this for a while and now i've got it to the point where i get a name
error.
any thoughts? thanks.
 

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

Similar Threads

Dcount Syntax Problem 5
syntax 1
DCount improper use of null 1
lost in error 3075 8
Too few parameters? 9
Syntax error in my query help 2
my search button stop working 0
Emailing Question from my DB 2

Top