Solved

DCount VBA syntax issue

Posted on 2013-12-02
2
411 Views
Last Modified: 2013-12-02
What is wrong with this?

Me.txtListingsSoldPending = Nz(DCount("[ID]", "tblTransactions", "[ListingAgent] = " & Forms!frmSelectDateRangeAndMembers!txtMemberName & " And [ListMonth] = " & Forms!frmSelectDateRangeAndMembers!txtMonth & " And [ListYear] = " & Forms!frmSelectDateRangeAndMembers!txtYear & " And [Pending] = True), 0)
0
Comment
Question by:SteveL13
2 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 39690020
What errors are you receiving?  Are all data types text?  If so, I believe you may need to qualify the form control values with apostrophes, e.g.

Me.txtListingsSoldPending = Nz(DCount("[ID]", "tblTransactions", "[ListingAgent] = '" & Forms!frmSelectDateRangeAndMembers!txtMemberName & "' And [ListMonth] = '" & Forms!frmSelectDateRangeAndMembers!txtMonth & "' And [ListYear] = '" & Forms!frmSelectDateRangeAndMembers!txtYear & "' And [Pending] = True), 0)

If the month and year values are numeric you'd leave off the apostrophes.
OM Gang
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39690028
Give this a try - You're Missing an end quote:


Me.txtListingsSoldPending = Nz(DCount("[ID]", "tblTransactions", "[ListingAgent] = " & Forms!frmSelectDateRangeAndMembers!txtMemberName & " And [ListMonth] = " & Forms!frmSelectDateRangeAndMembers!txtMonth & " And [ListYear] = " & Forms!frmSelectDateRangeAndMembers!txtYear & " And [Pending] = True"), 0) 

Open in new window

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now