Need help with syntax of If Then statement

  • Thread starter HLCruz via AccessMonster.com
  • Start date
H

HLCruz via AccessMonster.com

Private Sub Form_Current()
If Me.ListType = "Resident" And Me.Address Is Not Null Then
Me.cmdEditAddress.Visible = False
Else
Me.cmdEditAddress.Visible = True
End If

End Sub


I have a command button that I would like to be visible only if the record
meets two critera, that the ListType is Resident and their address is Not
Null. I've tried this several ways and haven't gotten it to work... thank
you to anyone who can help me out with this.

Heather
 
B

bohemian9485

HLCruz said:
Private Sub Form_Current()
If Me.ListType = "Resident" And Me.Address Is Not Null Then
Me.cmdEditAddress.Visible = False
Else
Me.cmdEditAddress.Visible = True
End If

End Sub

I have a command button that I would like to be visible only if the record
meets two critera, that the ListType is Resident and their address is Not
Null. I've tried this several ways and haven't gotten it to work... thank
you to anyone who can help me out with this.

Heather

What is the setup of your ListType? Is it a multi-column listbox?
 
K

Klatuu

Is Not Null is strictly an SQL statment. In VBA, use the IsNull function:

Private Sub Form_Current()
If Me.ListType = "Resident" And Not IsNull(Me.Address) Then
Me.cmdEditAddress.Visible = False
Else
Me.cmdEditAddress.Visible = True
End If

End Sub
 
R

Ron2006

If Dave's answer does not give you the results you want, then you
definitely have to look at
bohemian9485 's question. The value of the "bound column" of the
combobox/listbox(?) is the value you need to test for and that can
often be different than the value that is displayed (bound column is
column 1 BUT the length for column 1 is 0. - not shown).

Ron
 

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

Similar Threads


Top