Solved

Report field query syntax

Posted on 2014-04-21
1
408 Views
Last Modified: 2014-04-21
Can an expert tell me what is wrong with this syntax?

me.txtListingsTakenActual = Queries!qryTeamPerfRptListingsTaken.CountOfID WHERE "Listing Month" = me.txtMonthName AND "Listing Year" = me.txtYear

--Steve
0
Comment
Question by:SteveL13
1 Comment
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
Comment Utility
It looks like you are trying to run a query and place the results in a text box.  That isn't how it works.  A query returns a recordset.  It doesn't return a string.  Your syntax is also incorrect.

To open a recordset, you can use DAO or ADO.  If all you want is a single column returned, it might be easier to use DLookup()

me.txtListingsTakenActual = DLookup("CountOfID", "Queries!qryTeamPerfRptListingsTaken", "[Listing Month] '" = me.txtMonthName & "' AND [Listing Year]  = " & me.txtYear)

Based on what you started with, I am assuming that year and month are separate fields and that month is a string and year is numeric.  You will need to adjust the delimiters if that is incorrect.
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…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

728 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

15 Experts available now in Live!

Get 1:1 Help Now