Validating Date

foxtet

Registered User.
Local time
Today, 21:58
Joined
May 21, 2011
Messages
129
Hi Guys

how can I reference to field flightDate on tblCargoMaster
I want flight date to be earlier (older) than clearance date.

Private Sub Form_BeforeUpdate(Cancel As Integer)
dim fd = flightDate

If Me.ClearedDate < fd Then
Cancel = True
MsgBox "Goods not arrived, try again!"
End If
End Sub

your help is appreciated.

foxtet
 

Attachments

DLookup() for one Field in one record, or DAO.Recordset for more.
It seems to me you will need a criteria too, to define the flightDate of witch record (=flight) do you need.

ATB
 
try this if it works for you
 

Attachments

try this if it works for you
First of all Thank you for your help on this post
It worked well for clearance tab.

In loading details tab the criteria is
check for flight date and clearance date goods cannot be loaded on before these dates.

the logic i'm expecting is like;

if loaded date < flight date
msg "goods not arrived
else if
loaded date is < clearance date
msg" Goods need to cleared before loading"

In delivery details tab the criteria is
check for flight date, clearance date and loaded date, goods cannot be delivered before these dates.

the logic i'm expecting is like;

if delivered on <flight date
msg" goods not arrived"
else if
delivered on <clearance date
msg" goods not cleared"
else if
delivered date is <loaded date
msg " goods not loaded"
end if

foxtet
 
review the code of before_update of each subform.
 

Attachments

review the code of before_update of each subform.

provided code worked but it's good that if error message displays immediately after leaving date field.
code can execute;
after update or on lost focus of date field.
could you work on a solution which can work as mentioned.

foxtet
 

Users who are viewing this thread

Back
Top Bottom