Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is Date info passed 1

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,502
US

I have this Function where I accept Form and optional Date:

Code:
Public Function FormIsLockBy(ByRef frm As Form, Optional datDate As Date) As String
[green]'... How to check if datDate was passed?[/green]
End Function

Since datDate As Date is optional, I may or may not have it available in this Function.

How do I check if datDate was passed or not?

I did try
[tt]If datDate Is Nothing
If Not (datLetDate = vbNull) Then[/tt]
and some other ways, but no cigar...

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
hi,

If datDate <> 0 Then

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Andy,

faq707-4594

You can see that with no date passed the Watch Window value is [highlight #FCE94F]12:00:00 AM[/highlight] which is [highlight #FCE94F]0[/highlight].

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
When you use optional parameters and want to know if the parameter is missing from the procedure call, you use the IsMissing function.

If IsMissing(datDate) Then



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Skip, thanks. That worls nice :)

gmmastros,
Tried [pre]
If IsMissing(datDate) Then
Debug.Print "IsMissing = True"
Else
Debug.Print "IsMissing = False"
End If[/pre]
Always gor False, no matter if I did or did not pass the date :-(

I also tried this:
[pre]
Public Function FormIsLockBy(ByRef frm As Form, _
Optional datDate As Date = CDate("1/1/1900")) As String
[/pre]
and then checked the datDate against 1/1/1900 That also works, but it is not as nice and clean as Skip's

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Andy,

Make the darDate variable a Variant...
Code:
Public Function FormIsLockBy(ByRef frm As Form, Optional datDate As [highlight #FCE94F]Variant[/highlight]) As String
'...

Then the IsMissing() function will work as expected

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top