Hello All
Among the 20 or so controls on a UserForm I have 2 ComboBoxes: cboDateON and cboDateOFF, and a TextBox txtDaysFitted.
the cbo's are populated at Initialise() from a list of dates like this:
01 Jan 03
02 Jan 03
03 Jan 03
04 Jan 03
05 Jan 03
06 Jan 03
07 Jan 03
.........etc.
If that list is named "Date", I've done this:
With cboDateON
.RowSource = [Date].Address
.ListIndex = 0
End With
With cboDateOFF
.RowSource = [Date].Address
.ListIndex = 0
End With
What I'd like to do is a kind of DATEDIF thing to populate txtDaysFitted, something like this:
Private Sub cboDateOFF_Change()
txtDaysFitted.Value = (cboDateOFF.Value) - (cboDateON.Value)
End Sub
Everything I've tried so far, including CDate(cboDateON) returns an error of some sort, usually "Type Mismatch".
Can you give me a clue as to the correct way of doing this calculation?
P.S. I'm still working on a way to only do it when there's a value in both cbo's!![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
Chris
Among the 20 or so controls on a UserForm I have 2 ComboBoxes: cboDateON and cboDateOFF, and a TextBox txtDaysFitted.
the cbo's are populated at Initialise() from a list of dates like this:
01 Jan 03
02 Jan 03
03 Jan 03
04 Jan 03
05 Jan 03
06 Jan 03
07 Jan 03
.........etc.
If that list is named "Date", I've done this:
With cboDateON
.RowSource = [Date].Address
.ListIndex = 0
End With
With cboDateOFF
.RowSource = [Date].Address
.ListIndex = 0
End With
What I'd like to do is a kind of DATEDIF thing to populate txtDaysFitted, something like this:
Private Sub cboDateOFF_Change()
txtDaysFitted.Value = (cboDateOFF.Value) - (cboDateON.Value)
End Sub
Everything I've tried so far, including CDate(cboDateON) returns an error of some sort, usually "Type Mismatch".
Can you give me a clue as to the correct way of doing this calculation?
P.S. I'm still working on a way to only do it when there's a value in both cbo's!
![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
Chris