S
SlowArrow
Dear Form Gurus,
I've made a popup, modal dialog form in MS Access 2003 holding just an
MSCAL.OCX type Calendar control. I'm calling it from the MouseDown events of
some comboboxes of a non-modal sizable form. In the caller event I open the
form with the DoCmd.Open as a dialog form, and pass the value of the actual
date of the combobox together with the actual mouse position to the
Calendar-form. Clicking a date of the calendar control I dont close its form,
however i hide it, and I get back the selected date by the code in the caller
event. Then I close the Calendar-form.
However, this does not work correctly, if i use 2 comboboxes, the openarg
contains nothing. If i place do closing just before the opening of the
Calendar-form, then it works well. I would appreciate, if you explain this?
All the related code is below.
Thanks, ahead
SlowArrow
The caller form's codes:
Private Sub START_DATE_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
SetDate Me.START_DATE, X
End Sub
Private Sub END_DATE_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
SetDate Me.END_DATE, X
End Sub
Private Sub SetDate(ByRef cmbDate As ComboBox, X As Single)
Dim ResultFlag As Integer, hTitle As Integer, myDate As Date, strArgs As
String
hTitle = GetSystemMetrics(SM_CYSIZE) ' height of a button
in a window caption or title bar
If X > cmbDate.Width - 15 * 20 Then
If cmbDate.ListCount > 0 Then cmbDate.RemoveItem 0
cmbDate.AddItem cmbDate.Value
SendKeys "^{UP}{ESCAPE}"
Else
myDate = cmbDate.Value
strArgs = cmbDate.Text & "|" & CStr(Me.WindowTop + cmbDate.Top +
cmbDate.Height + hTitle * 20) & _
"|" & CStr(Me.WindowLeft + cmbDate.Left +
cmbDate.Width - Form_Calendar.Width) & "|" & cmbDate.Name
' Debug.Print "Form_Call: """ & strArgs & """ - " & CStr(ixCount)
' On Error Resume Next
DoCmd.Close acForm, CalendarDialog
DoCmd.OpenForm CalendarDialog, , , , , acDialog, strArgs
ResultFlag = Forms(CalendarDialog).Form.Tag
If ResultFlag = vbOK Then myDate =
Forms(CalendarDialog)!ocxCalendar.Value
' DoCmd.Close acForm, CalendarDialog
cmbDate.Value = myDate
End If
cmbDate.SetFocus
End Sub
The Calendar-form's codes:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Dim MyArray() As String
MyArray = Split(Me.OpenArgs, "|")
Me.ocxCalendar.Value = CDate(MyArray(0))
Me.Move Left:=Int(MyArray(2)), Top:=Int(MyArray(1))
' Debug.Print "Form_Load: """ & Me.OpenArgs & """ - " & CStr(ixCount)
' ixCount = ixCount + 1
End If
End Sub
Public Sub ocxCalendar_Click()
Me.Visible = False
Me.Tag = vbOK
End Sub
I've made a popup, modal dialog form in MS Access 2003 holding just an
MSCAL.OCX type Calendar control. I'm calling it from the MouseDown events of
some comboboxes of a non-modal sizable form. In the caller event I open the
form with the DoCmd.Open as a dialog form, and pass the value of the actual
date of the combobox together with the actual mouse position to the
Calendar-form. Clicking a date of the calendar control I dont close its form,
however i hide it, and I get back the selected date by the code in the caller
event. Then I close the Calendar-form.
However, this does not work correctly, if i use 2 comboboxes, the openarg
contains nothing. If i place do closing just before the opening of the
Calendar-form, then it works well. I would appreciate, if you explain this?
All the related code is below.
Thanks, ahead
SlowArrow
The caller form's codes:
Private Sub START_DATE_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
SetDate Me.START_DATE, X
End Sub
Private Sub END_DATE_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
SetDate Me.END_DATE, X
End Sub
Private Sub SetDate(ByRef cmbDate As ComboBox, X As Single)
Dim ResultFlag As Integer, hTitle As Integer, myDate As Date, strArgs As
String
hTitle = GetSystemMetrics(SM_CYSIZE) ' height of a button
in a window caption or title bar
If X > cmbDate.Width - 15 * 20 Then
If cmbDate.ListCount > 0 Then cmbDate.RemoveItem 0
cmbDate.AddItem cmbDate.Value
SendKeys "^{UP}{ESCAPE}"
Else
myDate = cmbDate.Value
strArgs = cmbDate.Text & "|" & CStr(Me.WindowTop + cmbDate.Top +
cmbDate.Height + hTitle * 20) & _
"|" & CStr(Me.WindowLeft + cmbDate.Left +
cmbDate.Width - Form_Calendar.Width) & "|" & cmbDate.Name
' Debug.Print "Form_Call: """ & strArgs & """ - " & CStr(ixCount)
' On Error Resume Next
DoCmd.Close acForm, CalendarDialog
DoCmd.OpenForm CalendarDialog, , , , , acDialog, strArgs
ResultFlag = Forms(CalendarDialog).Form.Tag
If ResultFlag = vbOK Then myDate =
Forms(CalendarDialog)!ocxCalendar.Value
' DoCmd.Close acForm, CalendarDialog
cmbDate.Value = myDate
End If
cmbDate.SetFocus
End Sub
The Calendar-form's codes:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Dim MyArray() As String
MyArray = Split(Me.OpenArgs, "|")
Me.ocxCalendar.Value = CDate(MyArray(0))
Me.Move Left:=Int(MyArray(2)), Top:=Int(MyArray(1))
' Debug.Print "Form_Load: """ & Me.OpenArgs & """ - " & CStr(ixCount)
' ixCount = ixCount + 1
End If
End Sub
Public Sub ocxCalendar_Click()
Me.Visible = False
Me.Tag = vbOK
End Sub