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

Double code

P: n/a
In this code Dmax is executed twice (when all is well). How can I make it so
that I only have to put de DMAX line one time in the code? Hope this is
clear.

Dim d as Date

If IsNull(DMax("[Date_request]", "tblRequest", "[Sender] = """ &
Forms![fTest]![Sender] & """")) Then
Exit Sub
Else
d = DMax("[Datum_request]", "tblRequest", "[Sender] = """ &
Forms![fTest]![Sender] & """")
endif

Thank you very much for any help.

Lars Brownie
Mar 16 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Got it. I found that the variant tye variable can hold null values.

"Lars" <la**@brownie.comschreef in bericht
news:fr**********@textnews.wanadoo.nl...
In this code Dmax is executed twice (when all is well). How can I make it
so that I only have to put de DMAX line one time in the code? Hope this is
clear.

Dim d as Date

If IsNull(DMax("[Date_request]", "tblRequest", "[Sender] = """ &
Forms![fTest]![Sender] & """")) Then
Exit Sub
Else
d = DMax("[Datum_request]", "tblRequest", "[Sender] = """ &
Forms![fTest]![Sender] & """")
endif

Thank you very much for any help.

Lars Brownie

Mar 16 '08 #2

P: n/a
On 16 Mar., 09:42, "Lars" <l...@brownie.comwrote:
In this code Dmax is executed twice (when all is well). How can I make it so
that I only have to put de DMAX line one time in the code? Hope this is
clear.

Dim d as Date

If IsNull(DMax("[Date_request]", "tblRequest", "[Sender] = """ &
Forms![fTest]![Sender] & """")) Then
Exit Sub
Else
d = DMax("[Datum_request]", "tblRequest", "[Sender] = """ &
Forms![fTest]![Sender] & """")
endif
There is always, when you have to use an expession of som
heavyness( code lines or execution speed) twice or more, the
possibility of using a temporary variable.
temp = dmax(......)
if not isnull(temp) then ....

... another thing is the nz statement
d=nz(expression,d)

--
Benny Andersen

Mar 16 '08 #3

P: n/a
Try:

dim d as Variant

d = DMax("[Datum_request]", "tblRequest", _
"[Sender] = """ & Forms![fTest]![Sender] & """")

if isnull(d) then
Exit Sub
end if

And, if the above is being run in form fTest, then:

d = DMax("[Datum_request]", "tblRequest", _
"[Sender] = """ & me![Sender] & """")
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com

Mar 16 '08 #4

P: n/a
Thanks for the me! reminder!
"Albert D. Kallal" <Pl*******************@msn.comschreef in bericht
news:uW5Dj.90276$pM4.52763@pd7urf1no...
Try:

dim d as Variant

d = DMax("[Datum_request]", "tblRequest", _
"[Sender] = """ & Forms![fTest]![Sender] & """")

if isnull(d) then
Exit Sub
end if

And, if the above is being run in form fTest, then:

d = DMax("[Datum_request]", "tblRequest", _
"[Sender] = """ & me![Sender] & """")
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com

Mar 16 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.