I have 5 boxes that take dates. I currently use a popup calendar with code that looks like this (cboOrig is a global Combobox, Orig is a global string)
then when the calendar is clicked
As you can see, on the selection of a date from the calendar, it sets the combobox to that value, then enables the next in the chain. Design spec says that in no instance can a date be input out of order. I have another function that when a button is clicked, adds all the boxes with a date in them into the database, and locks the fields for input. The next box without input is then enabled, ready for input. User error is fixed by clearing out all dates (ham-fisted, but effective).
So far it works OK, but not best. I got a feature request for a way of populating all the remaining fields with a set date, at two points in the process. No special flags have to be set, and I have a mostly-working setup, but it is a mess. At this stage, I either need to re-implement, or bodge it all.
I am looking for a better way of chaining the enabling of controls based on the state of the previous control. From my limited programming base, this doesn't seem to be something that VBA is geared for, unless I've missed something. Help/suggestions welcomed.
Code:
Private Sub Ready1_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
Set cboOrig = Me.ready1
Orig = "Ready1"
Me.QuoteCal.Visible = True
Me.QuoteCal.SetFocus
If Not IsNull(cboOrig) Then
QuoteCal.Value = cboOrig.Value
Else
QuoteCal.Value = Date
End If
End Sub
then when the calendar is clicked
Code:
Private Sub QuoteCal_Click()
If QuoteCal.Value > Date Then
MsgBox "Can't postdate checks", vbExclamation
Exit Sub
End If
cboOrig.Value = QuoteCal.Value
Select Case Orig
Case Is = "Ready1"
Me.Return1.Enabled = True
Me.JobForward.Enabled = False
Case Is = "Return1"
Me.ClientChk.Enabled = True
Me.SiteAmend.Enabled = True
Me.ProcFin.Enabled = True
Case Is = "ClientChk"
Me.ClientSiteApr.Enabled = True
Case Is = "ClientSiteApr"
Me.Return2.Enabled = True
End Select
cboOrig.SetFocus
QuoteCal.Visible = False
Set cboOrig = Nothing
End Sub
As you can see, on the selection of a date from the calendar, it sets the combobox to that value, then enables the next in the chain. Design spec says that in no instance can a date be input out of order. I have another function that when a button is clicked, adds all the boxes with a date in them into the database, and locks the fields for input. The next box without input is then enabled, ready for input. User error is fixed by clearing out all dates (ham-fisted, but effective).
So far it works OK, but not best. I got a feature request for a way of populating all the remaining fields with a set date, at two points in the process. No special flags have to be set, and I have a mostly-working setup, but it is a mess. At this stage, I either need to re-implement, or bodge it all.
I am looking for a better way of chaining the enabling of controls based on the state of the previous control. From my limited programming base, this doesn't seem to be something that VBA is geared for, unless I've missed something. Help/suggestions welcomed.