record not update until click subform

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
 

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

Top