Solved

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

Posted on 2013-12-03
4
360 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
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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.
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.

856 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