Visual Basic use of Null in if statements

  • Thread starter PowerPoint Jedi
  • Start date
P

PowerPoint Jedi

I am trying to run an event that checks the status of a field and if it is
null should do one action and if not null should do another. I can't seem to
get it to work. Any idea here is the code

Private Sub Quality_Approval_AfterUpdate()
If Forms![ERGR]![ME Approval] = Null Then
Forms![ERGR]![Quality Approval] = ""
Else
DoCmd.OpenForm "frmPassWord", acNormal, , "[Name] = '" & Me![Quality
Approval] & "'"
Forms![frmPassWord]![Source] = "Quality"
End If

End Sub

No matter what the value of [ME Approval] it performs the else action

Thanks
 
J

Jim Burke in Novi

Also, make sure the value is truly null and not a null string ("") or a space
(" "). These are all treated differently.
 
P

PowerPoint Jedi

Thanks everyone for the help.

The isnull solved the first problem I had. The extra information about the
"" and Null was helpful in another set of if statements I was working with.

For now I finished what I needed to do. Been a while since I have done any
programing so this was kind of a crash course
 

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