Results 1 to 8 of 8
  1. #1
    Casey Sanders is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    37

    IF IsNull set width to 0

    How would I code this? I'm trying to get a column to disappear when the value is null...if I set the width to 0" manually, the column disappears and it looks perfect...but basically I need something like this:



    Code:
    If IsNull([Control_Name]) Then
         SetProperty (Control_Name, Width, 0)
    End If
    ...this doesn't work for me to set the width, backcolor or anything...could someone please offer any ideas on how to code this??

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if isnull([Control_Name]) Then Control_Name.visible = false

    Assuming you're trying to make the entire control be invisible.

  3. #3
    Casey Sanders is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    37
    RP, thanks for the tip... I tried that and it does make it disappear, however, it leaves the white space there... when I set the control.width = 0, it collapses the whitespace... I have figured it out to some extent, but it changes every single line instead of just the one I'm working on...so basically now, I have to find a way to set the control.width = 0 (FOR THIS ENTRY ONLY), then have it run again for each entry...

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Is code in the Detail Format event? Seems I have tried to set properties of controls like this and just would not work. As you found out, the property setting applies to all instances of the control.

    Duplicate/related thread https://www.accessforums.net/reports...int-31954.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Casey Sanders is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    37
    yes...I've tried it a few different ways: https://www.accessforums.net/reports...int-31954.html ...sorry for the duplicate/related posts

  6. #6
    roaftech is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2012
    Location
    Romania
    Posts
    65
    I had a similar situation, but with control heights (I wanted different headers and footers on the first and last pages of a report)
    I found that it wasn't sufficient just to specify
    Me.Control.Height = 0
    but I then had to move the rest of the page content upwards to occupy the white space.

    If I understand your objective correctly, having set the control width to 0 you then need to move the next control leftwards to occupy the space vacated by the zero-width control. Note that screen postions are measured in TWIPS (1 cm = 567 TWIPS) and setting them can be somewhat erratic.

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    If you want the background color to come through you can also do

    me.control.backstyle = 0 (1 for normal)

  8. #8
    Casey Sanders is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    37
    The odd thing is that using the subform and setting width to 0 does exactly what I want it to, since it was set up automatically with columns, they just collapse and the next one scoots over where it should be. The problem is that once it runs and the width is set to 0, any other instances of that control are set to 0 even if they have data...so basically I need to figure out a way to get it to run the code for each instance and only set the width to 0 when the data isn't there.... looking into the "hasdata" method to see if that will do it....thank you all for your input!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. If Date IsNull
    By burrina in forum Forms
    Replies: 6
    Last Post: 01-10-2013, 07:23 PM
  2. If IsNull Value, Then need to be Zero
    By burrina in forum Forms
    Replies: 2
    Last Post: 11-18-2012, 02:53 AM
  3. Nuill or IsNull
    By Jerseynjphillypa in forum Queries
    Replies: 1
    Last Post: 05-18-2012, 07:28 AM
  4. IsNull
    By JJCHCK in forum Programming
    Replies: 3
    Last Post: 09-09-2011, 07:57 AM
  5. The section width is greater than the page width?
    By Gary_Marshall in forum Reports
    Replies: 2
    Last Post: 11-13-2009, 01:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums