Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run code when date deleted

Status
Not open for further replies.

NeilT123

Technical User
Jan 6, 2005
302
GB
Sorry, this is probably really simple but I am struggling.

On one of my forms the data is either provisional or confirmed. If the user adds a date to drillingdate the status automatically updates to confirmed using the following code.
Code:
Private Sub tbDrillingDate_AfterUpdate()
'when the drilling date is added this code changes the FertRecStatus to confirmed
If (Me.DrillingDate) > 0 Then
    Me.FertRecStatus = 0
End If
End Sub

What I would like is if the date is deleted that the status goes back to provisional but I don't know how to code for a blank record. So the code needs to be if drillingdate is blank or empty then change FertRecStatus = -1.

Suggestions please.
 
Something like this ?
Code:
If IsNull(Me!DrillingDate) Then
  Me!FertRecStatus = -1
Else
  Me!FertRecStatus = 0
End If

A shorter way:
Code:
Me!FertRecStatus = IsNull(Me!DrillingDate)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya NeilT123 . . .

Another way:
Code:
[blue]   Dim flg As Boolean
   
   If Not IsDate(Me.DrillingDate) Then flg = True
   Me.FertRecStatus = flg[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks guys, I used to long winded version because I understood that one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top