dbTalk Databases Forums  

Not Passing Optional Parm: Not Working

comp.databases.ms-access comp.databases.ms-access


Discuss Not Passing Optional Parm: Not Working in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
(PeteCresswell)
 
Posts: n/a

Default Not Passing Optional Parm: Not Working - 11-05-2011 , 05:20 PM






Got a function:
================================================== ===============
Public Function ResetDateFirst_GetOrCompute( _
ByVal
theCouponResetFrequencyID As Long, _
ByVal theIssueDate As
Date, _
ByVal theSecurityID
As Long, _
ByVal theWorkSwitch
As Boolean, _
Optional ByVal
theSettlementDate As Date _
) As Variant
================================================== ===============

When calling the function as in:
================================================== ===============
?ResetDateFirst_GetOrCompute(12,#10/21/2011#,25431,False)
================================================== ===============

I get
==============================
?ismissing(theSettlementDate)
False
==============================

But I have not passed anything.

In fact, IsDate(theSettlementDate) = True, and if I operate
using theSettlementDate, it actually works as if I had passed a
date of "12:00:00 AM".

I must be doing something wrong....

But what?
--
PeteCresswell

Reply With Quote
  #2  
Old   
Stuart McCall
 
Posts: n/a

Default Re: Not Passing Optional Parm: Not Working - 11-05-2011 , 07:31 PM






"(PeteCresswell)" <x@y.Invalid> wrote

Quote:
Got a function:
================================================== ===============
Public Function ResetDateFirst_GetOrCompute( _
ByVal
theCouponResetFrequencyID As Long, _
ByVal theIssueDate As
Date, _
ByVal theSecurityID
As Long, _
ByVal theWorkSwitch
As Boolean, _
Optional ByVal
theSettlementDate As Date _
) As Variant
================================================== ===============

When calling the function as in:
================================================== ===============
?ResetDateFirst_GetOrCompute(12,#10/21/2011#,25431,False)
================================================== ===============

I get
==============================
?ismissing(theSettlementDate)
False
==============================

But I have not passed anything.

In fact, IsDate(theSettlementDate) = True, and if I operate
using theSettlementDate, it actually works as if I had passed a
date of "12:00:00 AM".

I must be doing something wrong....

But what?
--
PeteCresswell
The IsMissing function can only be used with variant data types. That's
because variants have a 'missing' flag bit and ordinary types don't.

So you can either declare theSettlementDate as variant and use IsMissing to
check for existence, then convert to date using the Cdate function

or:

Set a default value of (say) 01/01/1980 and check for that. If you get a
hit, the argument is missing:

Optional theSettlementDate As Date = "01/01/1980"

Reply With Quote
  #3  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Not Passing Optional Parm: Not Working - 11-07-2011 , 06:49 PM



Per Stuart McCall:
Quote:
The IsMissing function can only be used with variant data types. That's
because variants have a 'missing' flag bit and ordinary types don't.

So you can either declare theSettlementDate as variant and use IsMissing to
check for existence, then convert to date using the Cdate function

or:

Set a default value of (say) 01/01/1980 and check for that. If you get a
hit, the argument is missing:

Optional theSettlementDate As Date = "01/01/1980"
I went with the Variant data type and all is well.

Thanks!... I never, ever would have doped that one out on my own.
--
PeteCresswell

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.