Rabu, 10 Mei 2017

Re: [MS_AccessPros] Date Validation

 

Phucon,


I prefer to put the logic into a single sub that is called from the BeforeUpdate of both controls.


Private Sub cboBeginDate_BeforeUpdate(Cancel As Integer)
    CheckDates
End Sub
 
Private Sub cboEndDate_BeforeUpdate(Cancel As Integer)
    CheckDates
End Sub

Sub CheckDates()
    With Me
        If IsDate(.cboBeginDate) And IsDate(.cboEndDate) Then  'check for valid dates
            .cmdClear.Enabled = True
            .cmdRun.Enabled = .cboBeginDate <= .cboEndDate
          Else
            .cmdClear.Enabled = False
            .cmdRun.Enabled = False
        End If
    End With
End Sub

I think I would add code to the cmdClear button to CheckDates.


Regards,

Duane




From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of saigonf7q5@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
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)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar