Connecting Tech Pros Worldwide Help | Site Map

Using dlookup twice

John
Guest
 
Posts: n/a
#1: Jun 10 '07
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


Rick Brandt
Guest
 
Posts: n/a
#2: Jun 10 '07

re: Using dlookup twice


John wrote:
Quote:
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


John
Guest
 
Posts: n/a
#3: Jun 10 '07

re: Using dlookup twice


Got it. Thanks.
john

"Rick Brandt" <rickbrandt2@hotmail.comschreef in bericht
news:xvQai.12012$4Y.6049@newssvr19.news.prodigy.ne t...
Quote:
John wrote:
Quote:
>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
>

Closed Thread