Solved

VBA syntax - One field was a number field and now is a text field

Posted on 2013-12-03
4
373 Views
Last Modified: 2013-12-03
An expert helped me with this code yesterday:

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

But now "txtMonthName" is a text field instead of a number field.  What should the syntax be to accommodate this change?

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39692997
Try this (embedded quotes):

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

Open in new window

0
 

Author Comment

by:SteveL13
ID: 39693025
Am getting a data type mismatch even though I know txtMonthName is a text field

???
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39693050
Double-check (again) the data type of all fields in tblTransactions.

For the above syntax, you should have

ListMonth -  Text
ListingAgent - Numeric
ListYear - Numeric
0
 

Author Comment

by:SteveL13
ID: 39693095
Your suggestion worked.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Many to Many From without subform 11 77
Access Query function 4 44
Calculation in a Report 13 35
How to append a form's present recordset to an existing table. 2 22
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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

740 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