Solved Compare Dates

mike60smart

Registered User.
Local time
Today, 06:11
Joined
Aug 6, 2017
Messages
2,274
Hi Everyone

I have a Subform which contains the following Unbound Controls

=[cboCarrier].Column(4) Control name is txtIns which displays the following Date: 11/04/1968
=[cboCarrier].Column(5) Control name is txtCargo which displays the following Date: 11/04/1971
=Date() Control name is txtDate to display todays date: 28/12/2022

I am trying to use the after Update of cboCarrier to display a warning if the Dates are Less Than Todays Date.

The after Update event is as follows and it current does nothing and gives no error. Can someone point out where I am going wrong?

Any help appreciated.

Code:
Private Sub cboCarrier_AfterUpdate()

10        On Error GoTo cboCarrier_AfterUpdate_Error
20    If Me.txtDate > Me.txtIns Then
30    MsgBox "Insurance has Expired", vbCritical
35    Me.cboCarrier.SetFocus
40    End If
50    If Me.txtDate > Me.txtCargo Then
60    MsgBox "Cargo Insurance Expired", vbCritical
65     Me.cboCarrier.SetFocus
70    End If

80        On Error GoTo 0
90        Exit Sub

cboCarrier_AfterUpdate_Error:

100       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cboCarrier_AfterUpdate, line " & Erl & "."

End Sub
 
Another way is to wrap with a cdate. cdate(me.txtins) >...
Or
=Cdate([cbocarrier].column(5))
 
Last edited:
Another way is to wrap with a cdate. cdate(me.txtins) >...
Or
=Cdate([cbocarrier].column(5))
Hi Pat & MajP

Pat I had formatted the dates as ShortDate

MajP That works just great.

Many thanks both for looking
 

Users who are viewing this thread

Back
Top Bottom