Solved

DLookup criteria problem

Posted on 2010-09-13
2
385 Views
Last Modified: 2013-11-28
Hi

I am using DLookup in an unbound field in a report. I want it to look up the field in a query with criteria for age = "<5" and with a year in the "Year" field in the query that matches the "rYear" field in the report. All fields are text data type. The query is called "All Other disease" and the field in the query is called "Abscess". The code I'm using works fine without the last part with year, but once I add in the year criteria I get #NAME.

=DLookup("Abscess","All Other disease","[Age]='<5' and [Year] like [rYear]")

Thanks.
0
Comment
Question by:ghaphis
  • 2
2 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 33669927
<All fields are text data type.>
1. Can I ask why age an year are text instead of numbers?
Aggregate functions are so much easier when using numbers.
2. Year is a Reserved word in Access so don't use it as a field name.
Besides you should make it more descriptive anyway.
(SchoolYear, StartYear, ...etc)

Try this in any event:
 DLookUp("Abscess","[All Other disease]","[Age]='<5'" & " AND [Year] =" & "'" & [rYear] & "'")

sample attached, see query1


Access-EEQ26470894DlookupTextStr.mdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33672482
;-)
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

763 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