ShyGuy wrote:
A while back I had found a link to a popup calendar that had a small
button that was placed to the right of any text box. By clicking on
the icon and selecting a date the text box was updated with that date.
You were able to use the icon (button) on multiple text boxes on the
form. I have lost the link and can't find any reference to it on my
machine.
Could someone lead me in the right direction?
Thank you.
Here's something I tried in A97. I'm not sure I'm doing it even close
to correctly, but it was fun trying.
frmDateIntoTextbox
txtFillFromPopup1 cmdTest1 (.Top = 0.5" for both)
txtFillFromPopup2 cmdTest2 (.Top = 0.8" for both)
'---Code behind frmDateIntoTextbox---
Option Compare Database
Option Explicit
Private Sub cmdTest1_Click()
DoCmd.OpenForm "frmPopupDatePicker"
End Sub
Private Sub cmdTest2_Click()
DoCmd.OpenForm "frmPopupDatePicker"
End Sub
'---End Code behind frmDateIntoTextbox---
frmPopupDatePicker (modal)
Built-in ActiveX Calendar control called PopUpDatePicker
cmdDone
'---Code behind frmPopupDatePicker---
Option Compare Database
Option Explicit
Dim MyClass As clsSelectedDate
Const TwipsPerInch = 1440
Private Sub cmdDone_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_Load()
Set MyClass = New clsSelectedDate
MyClass.SelectedDate = Date
PopUpDatePicker.Value = Date
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim ctl As Control
For Each ctl In Forms!frmDateIntoTextbox
If ctl.ControlType = acTextBox And Abs(ctl.Top - _
Forms!frmDateIntoTextbox.ActiveControl.Properties( "Top")) _
< 0.1 * TwipsPerInch Then
ctl.Value = MyClass.SelectedDate
End If
Next ctl
End Sub
Private Sub PopUpDatePicker_AfterUpdate()
MyClass.SelectedDate = PopUpDatePicker.Value
End Sub
'---End Code behind frmPopupDatePicker---
clsSelectedDate
'---Code in clsSelectedDate---
Option Compare Database
Option Explicit
Private mSelectedDate As Date
Public Property Let SelectedDate(dtIn As Date)
mSelectedDate = dtIn
End Property
Public Property Get SelectedDate() As Date
SelectedDate = mSelectedDate
End Property
'---End Code in clsSelectedDate---
When frmDateIntoTextbox is opened and one of the command buttons is
clicked, the form with the calendar control is opened. When cmdDone is
clicked, the date that was selected gets placed into any textboxes that
are vertically close to the command button that was clicked. I didn't
feel like trying to put the command buttons into a class. This might
not be even close to what you're looking for.
James A. Fortune
CD********@FortuneJames.com