Solved

DCount VBA syntax issue

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

760 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

16 Experts available now in Live!

Get 1:1 Help Now