DLookUp only returns first value

G

Guest

Please help. I am trying to generate a report that will look up a students
percent (a numeric value) in the table Semester Grade. I am having trouble
with the criteria.

The following statement returns the same value (for Semester Percent) for
each student:

DLookUp("[Semester Percent]","[Semester Grade]","[Student ID]=[Semester
Grade].[Student ID]")

The following statement doesn't recognize [Semester Grade] and treats it
like a parameter:

DLookUp("[Semester Percent]","[Semester Grade]","[Student ID]="&[Semester
Grade].[Student ID])

What's wrong?
 
A

Al Campagna

Cindy,
Well, actually you shouldn't have to do a Dlookup for SemesterPercent. If it is
correctly related to StudentID, it could be included in the query behind the report.
Perhaps you're using a table as the report Record Source... and SemesterPercent is in
another table?
It would be better to use a query as the RecordSource that that relates the two tables
via StudentID, and then all fields in both tables would be available for direct placement
on the report.

But... given that StudentID is on the main report... and the table is named "Semester
Grade"

= DLookUp("[Semester Percent]","Semester Grade","[Student ID] =
Reports!rptYourReportName![Student ID]")

should do it.
 
G

Guest

Thanks for the help. Your first advice was very helpful. Since students
grades are a weighted average I had to first group scores by category to
compute the overall percent. When I first tried to create a query that
combined both sets of information I recieved an error. It told me that I
couldn't combine data from [Semester Grade] to [All Scores] because it was an
agragate calculation. (Did I use that word correctly?).

Anyway, I just tried it again and it worked. In all of my attempts to get
DLookUp to work, I must have "fixed" something.

Thanks again for your help.


Al Campagna said:
Cindy,
Well, actually you shouldn't have to do a Dlookup for SemesterPercent. If it is
correctly related to StudentID, it could be included in the query behind the report.
Perhaps you're using a table as the report Record Source... and SemesterPercent is in
another table?
It would be better to use a query as the RecordSource that that relates the two tables
via StudentID, and then all fields in both tables would be available for direct placement
on the report.

But... given that StudentID is on the main report... and the table is named "Semester
Grade"

= DLookUp("[Semester Percent]","Semester Grade","[Student ID] =
Reports!rptYourReportName![Student ID]")

should do it.

--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


Cindy said:
Please help. I am trying to generate a report that will look up a students
percent (a numeric value) in the table Semester Grade. I am having trouble
with the criteria.

The following statement returns the same value (for Semester Percent) for
each student:

DLookUp("[Semester Percent]","[Semester Grade]","[Student ID]=[Semester
Grade].[Student ID]")

The following statement doesn't recognize [Semester Grade] and treats it
like a parameter:

DLookUp("[Semester Percent]","[Semester Grade]","[Student ID]="&[Semester
Grade].[Student ID])

What's wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top