By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,270 Members | 1,582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,270 IT Pros & Developers. It's quick & easy.

Unable to Hide control when the value is null

P: n/a
Pls help; I suppose following would be the right code to hide an empty control (TestMethod) but its not working; I checked by making a query- When I put a criteria IsNull the field is removed from the query results which means that the empty fields are actually "Null"; I tried using some existing values of the field test method- it works e.g when I substituted Null with "Slide Method" all entries containing "slide method" are removed/Hidden.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2. If Me.TestMethod = Null Then
  3. Me.TestMethod.Visible = False
  4. End If
  5.  
  6. End Sub
Nov 26 '10 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,494
You're on the right track, but Null isn't a value as such so cannot be compared against. You should use the function IsNull() instead. This returns TRUE if the parameter passed is Null. Your code could read :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     Me.TestMethod.Visible = (Not IsNull(Me.TestMethod))
  3. End Sub
This also handles the other point which you missed, which is to reset the control as visible for all other occasions ;-)
Nov 26 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.