Update only if null

maacky99

Access Newbie
Local time
Today, 14:54
Joined
Jun 3, 2004
Messages
35
I have an event procedure that enters the date shipped and closes a job out when the tracking number is scanned in our system.

How can I make this so it won't overwrite the date shipped (SHIPDATE) if there is already somethng entered? And/Or how do I change this so it will only be when the tracking number is entered not just copied, etc. Would that be on update and not lost focus?

Here is the code:
Private Sub UPSNO_LostFocus()
Dim da As Variant
If IsEmpty(Me.UPSNO.Value) = False Then
Me.SHIPDATE.Value = DATE
Else
End If

If IsEmpty(Me.UPSNO.Value) = False Then
Me.CLOSEDJOB.Value = True
Else
End If

End Sub


Thanks
 
You need to use the AfterUpdate event if you only want the code to run when the UPSNO field is updated.

Code:
Private Sub UPSNO_AfterUpdate()
Dim da As Variant
If IsNull(Me.SHIPDATE) Then
    Me.SHIPDATE = DATE
    Me.CLOSEDJOB = True
End If
End Sub
 
I will do that right now - thanks!!!
 

Users who are viewing this thread

Back
Top Bottom