Results 1 to 7 of 7
  1. #1
    Noodle1791 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Location
    Harlow
    Posts
    5

    Setting up a form 'on load' event

    Hi,

    I am trying to set up a form so that when it loads dependant on three check box states it will control the visibility of six buttons. each check box efectively controls the visibility state of two buttons. I came up with the code below but it always stops on the first 'IF' (CALIBRATE) with no errors. How do I make the code continue to effectively setup the form? I know its very basic but I have been googling for ages but to no avail. Thanks in advance!

    Private Sub Form_Load()
    If CALIBRATE.Value = True Then
    Me.Command43.Visible = True
    Me.Command46.Visible = False


    ElseIf MAINTAIN.Value = True Then
    Me.Command44.Visible = True
    Me.Command47.Visible = False
    ElseIf INSPECT.Value = True Then
    Me.Command44.Visible = True
    Me.Command47.Visible = False
    End If
    End Sub

  2. #2
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Noodle1791

    it looks like you do not have a option that covers calibrate. Value =false

    what your asking is to check that calibrate is true, but what happens if it's false?

    Code:
    If CALIBRATE.Value = True Then
     Me.Command43.Visible = True
     Me.Command46.Visible = False
    ElseIf CALIBRATE.Value = false
    
    rest of the code here
    steve

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Noodle1791

    below is an example of some code I use that checks a checkbox on a forms on load event, AssetDisposedOf is a checkbox field

    Code:
    If Me.AssetDisposedOf = True Then
          Me.Command75.Enabled = False
          Me.Command76.Enabled = False  
       Else
          Me.Command75.Enabled = True
          Me.Command76.Enabled = True
         
       End If
    hope this helps

    Steve

  4. #4
    Noodle1791 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Location
    Harlow
    Posts
    5
    Steve,

    Thanks for the response. I tidied that up and for the first check box state this works perfectly. How could I then continue the theme so that my code looks at the next check box state and hides or displays a different button based on its state? The code below works for the first check box as you have advised.

    If CALIBRATE.Value = True Then
    Me.Command43.Visible = True
    Me.Command46.Visible = False
    Else
    Me.Command43.Visible = False
    Me.Command46.Visible = True


    'ElseIf MAINTAIN.Value = True Then
    'Me.Command44.Visible = True
    'Me.Command47.Visible = False
    'Else
    'Me.Command44.Visible = False
    'Me.Command47.Visible = True


    'ElseIf INSPECT.Value = True Then
    'Me.Command45.Visible = True
    'Me.Command48.Visible = False
    'Else
    'Me.Command45.Visible = True
    'Me.Command48.Visible = False
    End If
    End Sub

  5. #5
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Mate

    personally when I do this I break each if out separately to test my logic something like the example below


    Code:
    If CALIBRATE.Value = True Then
     Me.Command43.Visible = True
     Me.Command46.Visible = False
     Else
     Me.Command43.Visible = False
     Me.Command46.Visible = True
    end if
    
    
    if MAINTAIN.Value = True Then
     Me.Command44.Visible = True
     Me.Command47.Visible = False
     Else
     Me.Command44.Visible = False
     Me.Command47.Visible = True
    end if
    
    if INSPECT.Value = True Then
     Me.Command45.Visible = True
     Me.Command48.Visible = False
     Else
     Me.Command45.Visible = True
     Me.Command48.Visible = False
    end if
    end sub
    which I suppose could then be shown like this

    Code:
    If CALIBRATE.Value = True Then
     Me.Command43.Visible = True
     Me.Command46.Visible = False
    
     Elseif calibrate.value=false then
     Me.Command43.Visible = False
     Me.Command46.Visible = True
    
    ElseIf MAINTAIN.Value = True Then
    Me.Command44.Visible = True
    Me.Command47.Visible = False
    
    ElseIf MAINTAIN.Value = False Then
    Me.Command44.Visible = false
    Me.Command47.Visible = true
    
    ElseIf INSPECT.Value = True Then
    Me.Command45.Visible = True
    Me.Command48.Visible = False
    
    Elseif INSPECT.VAlue=false then
    Me.Command45.Visible = True
    Me.Command48.Visible = False
     End If
     End Sub
    hope this helps put you in the right direction

    Steve

  6. #6
    Noodle1791 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2016
    Location
    Harlow
    Posts
    5
    Steve,

    Thanks so much! I couldn't see the wood for the trees and knew it was simple. Thanks a lot, have a good day. The following works perfectly!

    Private Sub Form_Load()
    If CALIBRATE.Value = True Then
    Me.Command43.Visible = True
    Me.Command46.Visible = False
    Else
    Me.Command43.Visible = False
    Me.Command46.Visible = True
    End If


    If MAINTAIN.Value = True Then
    Me.Command44.Visible = True
    Me.Command47.Visible = False
    Else
    Me.Command44.Visible = False
    Me.Command47.Visible = True
    End If


    If INSPECT.Value = True Then
    Me.Command45.Visible = True
    Me.Command48.Visible = False
    Else
    Me.Command45.Visible = False
    Me.Command48.Visible = True
    End If
    End Sub

  7. #7
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Mate

    no probs,

    Steve

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

Similar Threads

  1. form on load event
    By vicsaccess in forum Programming
    Replies: 2
    Last Post: 01-13-2016, 11:33 PM
  2. Replies: 1
    Last Post: 12-23-2015, 08:45 AM
  3. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  4. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  5. Form Load Event
    By shah1419 in forum Forms
    Replies: 5
    Last Post: 01-13-2013, 12:42 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