?
Solved

Report field query syntax

Posted on 2014-04-21
1
Medium Priority
?
415 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
[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
1 Comment
 
LVL 39

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 40012493
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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.
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…

719 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