Lebans Calendar code problem

G

Guest

I'm attempting to use the API Calendar from Mr Leban's site
Below is my execution code, I get a "By Ref Argument error" on the 2nd parm
of the function call. I followed the instructions exactly. Any ideas?

Private Sub butSetTarget_DblClick(Cancel As Integer)
' Uses Calendar Window
Dim dteFrom, dteTo As Date
dteFrom = Date
dteTo = 0
If ShowMonthCalendar(mc, dteFrom, dteTo) Then
MsgBox dteFrom
End If
End Sub
 
B

Brendan Reynolds

In VBA, your declaration line will result in dteFrom being created as a
Variant, only dteTo will be created as a Date. Try ...

Dim dteFrom As Date
Dim dteTo As Date
 
J

Jeff Conrad

This line:
Dim dteFrom, dteTo As Date

....will be interpreted as dteFrom as Variant.
It is best to declare each variable independently
to avoid confusion.

Change your code to this:

Private Sub butSetTarget_DblClick(Cancel As Integer)
' Uses Calendar Window
Dim dteFrom As Date, dteTo As Date
dteFrom = Date
dteTo = 0
If ShowMonthCalendar(mc, dteFrom, dteTo) Then
MsgBox dteFrom
End If
End Sub

--
Jeff Conrad
Access Junkie
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
G

Guest

oops, yes silly error. thanks

Brendan Reynolds said:
In VBA, your declaration line will result in dteFrom being created as a
Variant, only dteTo will be created as a Date. Try ...

Dim dteFrom As Date
Dim dteTo As Date
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top