Dlookup for Report with multiple criteria

echorley

Registered User.
Local time
Today, 09:03
Joined
Mar 11, 2003
Messages
131
I have a table where I want to look up the reading grade for a student for a specific term. I have a form where I select the student, then a command button to generate the report. The code below is not generating the correct name.

=DLookUp("[ReadingGrade]","ReportCard","[Name] =' " & [Forms]![Student Reports]![Student] & " ' " And "[Term] = 2")

This does generate the correct term, but not the correct student. Is the a quotation issue?

Thanks.
 
Try

=DLookUp("[ReadingGrade]","ReportCard","[Name] = '" & [Forms]![Student Reports]![Student] & "' And [Term] = '2'")

or

=DLookUp("[ReadingGrade]","ReportCard","[Name] = '" & [Forms]![Student Reports]![Student] & "' And [Term] = 2")
 
Success!

With the second one! Grr, I cannot seem to find the rules anywhere for using quotes " or the ' with the dlookup function.
Thanks!!
 
To embed quotes inside another string:

1. You can use double quotes: ""
2. You can use the apostrophe: '

In:

=DLookUp("[ReadingGrade]","ReportCard","[Name] = '" & [Forms]![Student Reports]![Student] & "' And [Term] = 2")

We really wanted to end up with something like:

=DLookUp("[ReadingGrade]","ReportCard","[Name] = 'Jones' And [Term] = 2")

In this case we wanted to embed quoutes so we used ' around the name Jones. I'm not sure if there is an upside or downside to using double qoutes vs the apostrophe.

In this case it's really just the same as concatenating a string...
 

Users who are viewing this thread

Back
Top Bottom