Results 1 to 2 of 2
Thread: force fields (2000)
2005-03-29, 10:19 #1
- Join Date
- May 2003
- Manchester, Gtr Manchester, England
- Thanked 0 Times in 0 Posts
force fields (2000)
Hello, have a combo where if a certain value is selected I then need to have a second field (a date field) forced so that the user has to enter a date. How can I code this in VBA? So if combo is called received and if value 1 is selected I then need to have field 'date' forced before user can move on.
2005-03-29, 10:33 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: force fields (2000)
You can set focus to the date text box in the After Update event of the combo box.
You can check whether a date has been entered in the Before Update event of the date text box. (I wouldn't actually call it 'date' since that is a built-in function)
With a combo box named cmbReceived and a text box named txtDate:
Private Sub cmbReceived_AfterUpdate
' Did the user select 1?
If Me.cmbReceived = 1 Then
' If so, set focus to the date text box.
Private Sub txtDate_BeforeUpdate(Cancel As Integer)
' Did the user select 1 in the combo box and leave the date blank?
If Me.cmbReceived = 1 And IsNull(Me.txtDate) Then
' If so, issue a warning ...
MsgBox "You MUST enter a date!", vbInformation
' ... and cancel the update.
Cancel = True