S
Song Su
I have two combo box controls on main form cboFrom and cboTo which when
clicking drop down, bring calendar control.
Problems are:
1. Clicking a date on calendar control, date is on the combo control but
record not updated until clicking subform.
2. User might just type date instead of click drop down. When type date in
cboFrom, date is entered but record not saved until clicking subform.
2. If user types date in cboTo, it always reverto to current date!! And same
problem as above: record not saved until clicking subform.
Where did I do wrong? Here are my codes:
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox
Private Sub cboFrom_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Set cboOriginator = cboFrom
ocxCalendar.Visible = True
ocxCalendar.SetFocus
If Not IsNull(cboFrom) Then
ocxCalendar.Value = cboFrom.Value
Else
ocxCalendar.Value = Date
End If
Me.Dirty = False
End Sub
Private Sub cboTo_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Set cboOriginator = cboTo
ocxCalendar.Visible = True
ocxCalendar.SetFocus
If Not IsNull(cboTo) Then
ocxCalendar.Value = cboTo.Value
Else
ocxCalendar.Value = Date
End If
Me.Dirty = False
End Sub
Private Sub ocxCalendar_Click()
cboOriginator.Value = ocxCalendar.Value
cboOriginator.SetFocus
ocxCalendar.Visible = False
Set cboOriginator = Nothing
End Sub
clicking drop down, bring calendar control.
Problems are:
1. Clicking a date on calendar control, date is on the combo control but
record not updated until clicking subform.
2. User might just type date instead of click drop down. When type date in
cboFrom, date is entered but record not saved until clicking subform.
2. If user types date in cboTo, it always reverto to current date!! And same
problem as above: record not saved until clicking subform.
Where did I do wrong? Here are my codes:
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox
Private Sub cboFrom_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Set cboOriginator = cboFrom
ocxCalendar.Visible = True
ocxCalendar.SetFocus
If Not IsNull(cboFrom) Then
ocxCalendar.Value = cboFrom.Value
Else
ocxCalendar.Value = Date
End If
Me.Dirty = False
End Sub
Private Sub cboTo_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Set cboOriginator = cboTo
ocxCalendar.Visible = True
ocxCalendar.SetFocus
If Not IsNull(cboTo) Then
ocxCalendar.Value = cboTo.Value
Else
ocxCalendar.Value = Date
End If
Me.Dirty = False
End Sub
Private Sub ocxCalendar_Click()
cboOriginator.Value = ocxCalendar.Value
cboOriginator.SetFocus
ocxCalendar.Visible = False
Set cboOriginator = Nothing
End Sub