Solved

DCount VBA syntax issue

Posted on 2013-12-02
2
420 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

773 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