Results 1 to 3 of 3
  1. #1
    Archer's Avatar
    Archer is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2019
    Location
    Down Under
    Posts
    16

    Error Setting Visible Property based on other field value in Access Form

    Hi guys.

    When trying to run the following code, I keep getting Run-time error '424': Object required. Am I overlooking something obvious?

    Private Sub Form_Current()
    Dim Demographic_ID As Integer

    If Me.Demographic_ID Is Null Then
    Me.Consultant.Visible = False
    Me.Contact_Date.Visible = False
    Me.Contact_Approval_Given.Visible = False
    Me.Nurse.Visible = False
    Me.Comments.Visible = False



    End If
    End Sub

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    In VBA you need to use IsNull() , so try a new line of


    Code:
    Private Sub Form_Current()
      Dim Demographic_ID As Integer
    
      If IsNull(Me.Demographic_ID) Then
         Me.Consultant.Visible = False
         Me.Contact_Date.Visible = False
         Me.Contact_Approval_Given.Visible = False
         Me.Nurse.Visible = False
         Me.Comments.Visible = False
       End If
    End Sub
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Join Date
    Apr 2017
    Posts
    1,792
    And declaring a variable with name Demographic_ID in code whil there is a control with same name on form is at least confusing, and also pointless - you never used it!

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

Similar Threads

  1. Replies: 7
    Last Post: 06-07-2018, 04:49 PM
  2. Replies: 16
    Last Post: 03-26-2015, 08:35 PM
  3. Replies: 1
    Last Post: 10-25-2012, 12:58 PM
  4. Replies: 6
    Last Post: 09-27-2011, 04:39 PM
  5. Setting visible property of subreport?
    By GaryElwood in forum Reports
    Replies: 1
    Last Post: 09-23-2011, 07:49 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