If...Then help

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
 
J

John Spencer (MVP)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top