Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

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

18 Experts available now in Live!

Get 1:1 Help Now