By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

Using dlookup twice

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.