Phucon,
I prefer to put the logic into a single sub that is called from the BeforeUpdate of both controls.
I think I would add code to the cmdClear button to CheckDates.
Regards,
Duane
Sent: Wednesday, May 10, 2017 9:47 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Date Validation
Hello
I am doing a date validation, comparing the Begin Date and the End Date. The RUN button will be enabled only when the Begin Date is less than the End Date. The code that I have here, sometimes it's working right and sometimes it doesn't. I wasn't able to figured out the errors. What is the correct way to do it?
Phucon
Private Sub cboBeginDate_BeforeUpdate(Cancel As Integer)
With Me
If Not .cboBeginDate & "" = "" And Not .cboEndDate & "" = "" Then
If .cboBeginDate.Value <= .cboEndDate.Value Then
!cmdRun.Enabled = True
!cmdClear.Enabled = True
Else
!cmdRun.Enabled = False
End If
End If
End With
End Sub
Private Sub cboEndDate_BeforeUpdate(Cancel As Integer)
With Me
If Not .cboBeginDate & "" = "" And Not .cboEndDate & "" = "" Then
If .cboBeginDate.Value <= .cboEndDate.Value Then
!cmdRun.Enabled = True
!cmdClear.Enabled = True
Else
!cmdRun.Enabled = False
End If
End If
End With
End Sub
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar