469,575 Members | 1,668 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

Using dlookup twice

To prevent the null-error from showing up when dlookup returns false I
created the code beneath which doesn't seem very elegant. How can I code
this without having to use the dlookup twice?

If Not IsNull(DLookup("[Bestandsnaam]", "tbSoortVerzoek", "[Soort_verzoek] =
""" & Forms![frmVerzoek]!Soort_verzoek & """")) Then
strForm = DLookup("[Bestandsnaam]", "tbSoortVerzoek",
"[Soort_verzoek] = """ & Forms![frmVerzoek]!Soort_verzoek & """")
Else
MsgBox ("There is no form available")
Exit Sub
End If

Thanks,
john
Jun 10 '07 #1
2 1588
John wrote:
To prevent the null-error from showing up when dlookup returns false I
created the code beneath which doesn't seem very elegant. How can I
code this without having to use the dlookup twice?

If Not IsNull(DLookup("[Bestandsnaam]", "tbSoortVerzoek",
"[Soort_verzoek] = """ & Forms![frmVerzoek]!Soort_verzoek & """"))
Then strForm = DLookup("[Bestandsnaam]", "tbSoortVerzoek",
"[Soort_verzoek] = """ & Forms![frmVerzoek]!Soort_verzoek & """")
Else
MsgBox ("There is no form available")
Exit Sub
End If
Dim VariableName as Variant
VariableName = DLookup(...

If Not IsNull(VariableName ) Then
strForm = VariableName
....

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jun 10 '07 #2
Got it. Thanks.
john

"Rick Brandt" <ri*********@hotmail.comschreef in bericht
news:xv*****************@newssvr19.news.prodigy.ne t...
John wrote:
>To prevent the null-error from showing up when dlookup returns false I
created the code beneath which doesn't seem very elegant. How can I
code this without having to use the dlookup twice?

If Not IsNull(DLookup("[Bestandsnaam]", "tbSoortVerzoek",
"[Soort_verzoek] = """ & Forms![frmVerzoek]!Soort_verzoek & """"))
Then strForm = DLookup("[Bestandsnaam]", "tbSoortVerzoek",
"[Soort_verzoek] = """ & Forms![frmVerzoek]!Soort_verzoek & """")
Else
MsgBox ("There is no form available")
Exit Sub
End If

Dim VariableName as Variant
VariableName = DLookup(...

If Not IsNull(VariableName ) Then
strForm = VariableName
...

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Jun 10 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Iain Miller | last post: by
8 posts views Thread by Christine Henderson | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.