Empty field on Close

H

Hanksor

I have a report that I would like to determine if a given field is empty on
close. I have the following code;

Private Sub Report_Close()
Dim strID As String
Dim strSql As String

strID = Nz(Me!CardHolderIDtxt, "")



If strID <> "" Then
Blaa, blaa, blaa
End If

End Sub

It crashed at the strID = NZ line. What am I doning wrong? Any help will
be appreciated.
 
B

Brendan Reynolds

I can't reproduce this. The code below runs without any crash or error for
me. Are you getting any error message?

Private Sub Report_Close()

Debug.Print Nz(Me!TestText, "")

End Sub

Note that this code will return the value of the field in the last record
accessed, which is not necessarily the last record in the report's
recordset. In my tests, when I opened the report in preview mode, the code
returned the value from the first record on the first page *not* viewed,
e.g. if there were three records per page and I did not scroll to page two,
the value from the fourth record was returned. If I scrolled to page two,
the value from the seventh record was returned.
 
H

Hanksor

I was afraid I wasn't very clear on this. What I want to do is; if the
report has no records, I want to something and if the report has record(s) I
want to do something else OnClose.
 

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