If...Then help

  • Thread starter Thread starter shaggles
  • Start date Start date
S

shaggles

I'm trying to create an history table for several fields
on my database. What I want is to copy the old info from
these fields into a history table before updating the main
table. The code below seems to work but I want to create
an if...then statement that will not update the history
table if the fields are empty. I've tried If [Review Date]
=Null and If [Review Date]=Dirty but neither of those gave
the desired result.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("BranchReview_historical",
dbOpenDynaset)
rst.AddNew
rst("Branch") = Branch
rst("Review Date") = [Review Date]
rst("Score") = Score
rst("Notes") = Notes
rst.Update
End Sub
 
Try using the IsNull function

If IsNull([Review Date]) = False Then
'do your stuff
End If

Or

If Len([Review Date] & vbnullstring) > 0 then
'Do your stuff
End If
 
Back
Top