Why "no current record" on a DLookup function?

L

Laurel

This is the first line of a function that I execute repeatedly throughout my
app. But now I have a situation where it is giving me a "no current record"
error. How could that be with this line? The context is that I have a form
that collects data and then opens a report. If I close the report and then
re-execute the form, to print another report, I get the "No current
record..." error at this line. I'm mystified. Will appreciate any help.

ls_firstname = DLookup("First_Name", "tblStudents", "[student_id] = " &
ai_StudentID)
 
L

Laurel

That was it. The function was being called by the report. I had this in
one of the header text items: =fncStudentName([student_id]).
The second time I ran the report I was adding the current day, and so there
were no records for the report. I'll add a check.

The truly weird thing, though, was that even when I hovered over ai_student
with the mouse in the debugger, I would get that "no current record" error.
You'd think the function would just treat it as a null. How did it know why
the value wasn't good???

Thanks for helping me see the obvious.

Douglas J. Steele said:
What is "ai_StudentID"?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Laurel said:
This is the first line of a function that I execute repeatedly throughout
my
app. But now I have a situation where it is giving me a "no current
record"
error. How could that be with this line? The context is that I have a
form
that collects data and then opens a report. If I close the report and
then
re-execute the form, to print another report, I get the "No current
record..." error at this line. I'm mystified. Will appreciate any help.

ls_firstname = DLookup("First_Name", "tblStudents", "[student_id] = "
&
ai_StudentID)
 

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