Date Time Picker (MSComCtl2.DTPicker.2)

G

Guest

I use the date time picker alot in my forms. In my current database I use
the following code to set the default date of the dt picker control on my
form under the onload event:

Private Sub Form_Load()
Dim m As Integer
Dim d1 As Integer
Dim d2 As Integer
Dim y As Integer


m = Format((DateAdd("d", (2 - (Weekday(Date))), Date)), "m")
d1 = Format((DateAdd("d", (2 - (Weekday(Date))), Date)), "d")
d2 = Format((DateAdd("d", (2 + (Weekday(Date))), Date)), "d")
y = Format((DateAdd("d", (2 - (Weekday(Date))), Date)), "yyyy")

Me.DT_Start_Date.Month = m
Me.DT_Start_Date.Day = d1
Me.DT_Start_Date.Year = y

Me.DT_End_Date.Month = m
Me.DT_End_Date.Day = d2
Me.DT_End_Date.Year = y

End Sub

Keep in mind that I use this code with similar named controls on another
form within the same database with no problems, BUT, on another form I get
Run-time error '438'. What's even more odd is the fact that the form works
on my PC, but not on two other PC's. I've checked my libraries and I made
sure to register the active x control on all machines. What gives?
 
A

Arvin Meyer [MVP]

Try checking the registration again, and make sure that the control is the
same version as the one in the original database. Failing that, use an
Access based solution, like the one on my website that has worked (with
conversion when necessary) for every version of Access from Access 2.0 on:

http://www.datastrat.com/Download/Calendar2K.zip

or Stephen Lebans' api based one that also doesn't require an ActiveX
control:

http://www.lebans.com/monthcalendar.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 

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

Similar Threads


Top