Using Dlookup to format reports

G

Guest

I'm trying to use some dlookups on the onFormat event of the detail section
of my report to hide certain parts of the report on a record-by-record basis.
The dlookup always seems to return NULL even when the item exists.

Dim test As Variant
test = DLookup("[evaluation_id]", "tblEvaluation", "[idea_id]=" &
Me!idea_id)
If test <> Null Then
Me.labelEvaluation.Visible = True
Me.lineEvaluation.Visible = True
Me.subreportEvaluation2.Visible = True
End If

evaluation_id and idea_id are fields in tblEvaluation. Me!idea_id is a text
box on the report.

Any help would be gratefully recieved!

Chris
 
G

Guest

If test <> Null Then

This is a very common mistake. Nothing will ever test true against Null.
Even Null = Null returns False. The correct method is to use the IsNull
function:

If Not IsNull(test) Then
 
G

Guest

Thanks for that. I've only been using VB for a week or so (I'm much more
used to C) and I keep finding alarming gaps in my basic (excuse the pun)
knowledge.

Chris

Klatuu said:
If test <> Null Then

This is a very common mistake. Nothing will ever test true against Null.
Even Null = Null returns False. The correct method is to use the IsNull
function:

If Not IsNull(test) Then

Chris_h said:
I'm trying to use some dlookups on the onFormat event of the detail section
of my report to hide certain parts of the report on a record-by-record basis.
The dlookup always seems to return NULL even when the item exists.

Dim test As Variant
test = DLookup("[evaluation_id]", "tblEvaluation", "[idea_id]=" &
Me!idea_id)
If test <> Null Then
Me.labelEvaluation.Visible = True
Me.lineEvaluation.Visible = True
Me.subreportEvaluation2.Visible = True
End If

evaluation_id and idea_id are fields in tblEvaluation. Me!idea_id is a text
box on the report.

Any help would be gratefully recieved!

Chris
 
G

Guest

Oh, I C what you say :)

Chris_h said:
Thanks for that. I've only been using VB for a week or so (I'm much more
used to C) and I keep finding alarming gaps in my basic (excuse the pun)
knowledge.

Chris

Klatuu said:
If test <> Null Then

This is a very common mistake. Nothing will ever test true against Null.
Even Null = Null returns False. The correct method is to use the IsNull
function:

If Not IsNull(test) Then

Chris_h said:
I'm trying to use some dlookups on the onFormat event of the detail section
of my report to hide certain parts of the report on a record-by-record basis.
The dlookup always seems to return NULL even when the item exists.

Dim test As Variant
test = DLookup("[evaluation_id]", "tblEvaluation", "[idea_id]=" &
Me!idea_id)
If test <> Null Then
Me.labelEvaluation.Visible = True
Me.lineEvaluation.Visible = True
Me.subreportEvaluation2.Visible = True
End If

evaluation_id and idea_id are fields in tblEvaluation. Me!idea_id is a text
box on the report.

Any help would be gratefully recieved!

Chris
 

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