Solved

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

Posted on 2013-12-03
4
380 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

688 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