Results 1 to 6 of 6
  1. #1
    acedeno is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    4

    Question Visibility based on whether table field is empty

    Hello I'm new to using access and I'm having trouble with syntax for using VBA on a report in Access 2007.
    I need to some hide 3 text boxes if one of my fields is empty in a table. The table name is: 'ALM-RESP' with rows grouped by: 'TAG NAME' and the field I'm checking is: 'Rev 002 Author'. I've tried having a rectangle to cover it up but I'm having trouble using the IsNull command and setting the visibility of the rectangle. Here's my code:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If IsNull([ALRM-RESP]![TAG NAME]![Rev 002 Author].Value) Then REV2BOX.Visible = False


    End Sub

    Basically I'm having trouble checking if the field is empty and then setting the visibility. Any advice?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    VBA syntax is not correct and a rectangle control should not be needed:
    If IsNull(Me.[Rev 002 Author]) Then Me.textboxname.Visible = False

    Is this report filtered to a single record or are there multiple records listed continuously in detail section? The above might not work for continuous records.

    An expression in textbox ControlSource should accomplish:
    =IIf(IsNull([Rev 002 Author]), Null, [fieldname])
    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.

  3. #3
    acedeno is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    4
    Like I said I'm new to access so I don't quite know what the terms filtered to a single record or continuous records means.
    But I have grouped my data by TAG NAME with a Forced Page Break after a TAG NAME footer since I want a new page for each TAG NAME (with the corresponing data on the page of the report).
    Control Source doesn't quite work because I have a border on the text box that I need to disappear as well.
    I'm still trying your first code. Thanks for the reply!

  4. #4
    acedeno is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    4
    May I ask how Me works? Since I've grouped my data by TAG NAME (with a Forced new page after the TAG NAME footer) will it know that I'm on a different TAG NAME?
    For example if the TAG NAME is 'VALVE' and Rev 002 Author is Bob, I want the text box for that report page to be visible. If say the next TAG NAME is PIPE and Rev 002 Author field is empty in my table, then I want the page PIPE is on to not have the text box be visible.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Me is shorthand alias for the form or report the code is behind.

    Showing color border does complicate. Unfortunately, BorderStyle is not a setting available with ConditionalFormatting. Would be so nice if it was - like for cells in Excel.

    Suggested code does not consider the TAG NAME. If Author is Null the condition is met.

    Your code syntax makes no sense if TAG NAME and REV 002 Author are fields. What is ALRM-RESP?
    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.

  6. #6
    acedeno is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    4
    ALRM-RESP is a table with various fields two of which are TAG NAME and REV 002 Author. In my report I reference this table and group my data by TAG NAME. All of my rows in the table ALRM-RESP have a TAG NAME but not all of them have REV 002 Author. So I want to display a text box only if that row has a REV 002 Author filled in.

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

Similar Threads

  1. Replies: 2
    Last Post: 01-31-2013, 07:44 PM
  2. Field visibility based on ComboBox selection
    By cactuspete13 in forum Forms
    Replies: 3
    Last Post: 01-30-2013, 03:37 PM
  3. Replies: 8
    Last Post: 01-25-2012, 02:07 PM
  4. Replies: 4
    Last Post: 11-20-2011, 01:08 PM
  5. Visibility based on Combo selection
    By jlclark4 in forum Forms
    Replies: 1
    Last Post: 12-22-2010, 11:42 AM

Tags for this Thread

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