473,486 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1766
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5149
by: Bobbak | last post by:
Hello All, I am having trouble with this forum I am developing, I have this form that allows the users to add or modify employee information, and there's a text box called txtEmployeeLogin, and...
1
3153
by: John Hargrove | last post by:
I am building a database to manage test samples in an environmental laboratory. I am learning Access as I go and don't know much about the programming aspects. I hope to make the application...
5
1889
by: Iain Miller | last post by:
Trying to get my head round building a DB to analyse phone bills. On the surface its fairly simple - duration in seconds x cost per minute/60. The problem arises with working out what time of...
8
4302
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
4
8657
by: jpr | last post by:
Hello, I have created menu bars for my access application and now would like to transfer many pieces of code in modules so that they can run using macros. I beleive this is the only way I can...
2
2834
by: jonvan20 | last post by:
I have been having trouble with a simple Dlookup command that was Reccommended to me by a nice fellow named Vic, On the other hand I have statements like this that wont run they give me a run time...
3
2423
reginaldmerritt
by: reginaldmerritt | last post by:
I'm using Dlookup to search a table for the first record it comes across that has a date >= the date i specifiy. e.g. formateddate = format(Me.SelectedDate,"mmddyy") VarX = DLookup("",...
3
2278
by: Constantine AI | last post by:
Hi can anybody help me with this problem? I have a customer order form with a sales order line subform. The subform contains products ordered by customers, each (wooden) product can come in two...
15
3086
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.