Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can you open the FORM2 2 32
Access 2016 - query 23 61
Passing variables to a function 6 36
Switch 5 17
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

777 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