P
pietlinden
I have a database that someone else wrote that I have been contracted
to work on to add a few features.
One feature I have been tasked to add is to implement something like
the adhCalendar from the Developer's Handbook to all the textboxes
formatted as not general date. Finding these programmatically is
fine. I wrote some code to open the forms in design view and loop
through the controls and log them to a table.
For each of these controls, I wanted to add the adhCalendar code call.
(Can't quote the VBA exactly, as my newer copy of the book is still in
the mail, but I do know it's in the ADH Desktop volume.) Just in case
I'm not making myself clear (and I'm tired so there's a good chance!),
I'll give an example.
Each of the controls the code finds need exactly the same VBA.
me.Value = adhCalendar(Me.Value)
It would look something like this (well, in my dreams, anyway!)
Private Sub Command8_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
If ctl.Format = "Short Date" Then
'---This is the line I'm having a problem with!
ctl.OnDblClick = "adhCalendar(" & ctl.Value & ")"
End If
End If
Next ctl
End Sub
is there a method to add event code to an object? So I could loop
through all the controls as above and add the same code to the Enter
and Double-Click events of each one?
the Enter code would check
if ctl.IsNull(ctl.Value) then
ctl.Value = adhCalendar()
end if
in the double-click
ctl.Value=adhCalendar(ctl.Value)
I could do it manually, sure. I was just wondering if there were a
way to do it programmatically. <g> I know, it sounds like I'm being
really lazy. but I'm trying to learn something, so I guess I'll play
with it in the meantime.
Thanks,
Pieter
to work on to add a few features.
One feature I have been tasked to add is to implement something like
the adhCalendar from the Developer's Handbook to all the textboxes
formatted as not general date. Finding these programmatically is
fine. I wrote some code to open the forms in design view and loop
through the controls and log them to a table.
For each of these controls, I wanted to add the adhCalendar code call.
(Can't quote the VBA exactly, as my newer copy of the book is still in
the mail, but I do know it's in the ADH Desktop volume.) Just in case
I'm not making myself clear (and I'm tired so there's a good chance!),
I'll give an example.
Each of the controls the code finds need exactly the same VBA.
me.Value = adhCalendar(Me.Value)
It would look something like this (well, in my dreams, anyway!)
Private Sub Command8_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
If ctl.Format = "Short Date" Then
'---This is the line I'm having a problem with!
ctl.OnDblClick = "adhCalendar(" & ctl.Value & ")"
End If
End If
Next ctl
End Sub
is there a method to add event code to an object? So I could loop
through all the controls as above and add the same code to the Enter
and Double-Click events of each one?
the Enter code would check
if ctl.IsNull(ctl.Value) then
ctl.Value = adhCalendar()
end if
in the double-click
ctl.Value=adhCalendar(ctl.Value)
I could do it manually, sure. I was just wondering if there were a
way to do it programmatically. <g> I know, it sounds like I'm being
really lazy. but I'm trying to learn something, so I guess I'll play
with it in the meantime.
Thanks,
Pieter