Results 1 to 4 of 4
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    VBA Code Help

    What I am wanting is that when I check Check111 and Check1234 together, that these fields will
    become "Unenabled." Which the first code works great for that. The problem that I am running into
    is that in the second code, if I check Check1212 or Check1418 and leave Check111 and Check1234 blank
    then Check1212 and Check1418 are still Enabled. I am wanting in a sense Check1212 and Check1418 to
    overrule any other code so that if either of those are checked everything is locked. I want Check111
    and Check1234 to become "Disabled" if Either check1212 or Check1418 are checked, but I also want
    check1234, Check111 and Check116 to become "Disabled" if Check111 and Check1234 are checked. I am


    assuming the problem is that I am duplicating code and confusing access, but I don't know of a simpler
    way to write the code that would correct this. I tried to move the first code, to the After Update
    section of the Form, instead of the On Current, but this didn't fix it. Any ideas?

    Code:
     Private Sub Form_Current()  
    If Me.Check111 = True And Me.Check1234 = True Then 
      Me.Check1234.Enabled = False  
    Me.Check111.Enabled = False  
    Me.check116.Enabled = False 
      Else 
      Me.Check1234.Enabled = True  
    Me.Check111.Enabled.Enabled = True  
    Me.check116.Enabled = True 
      End If  
    End Sub

    Code:
    
    
    Code:
     
      Private Sub Form_Current()  
    If Me.Check1212 = True Or Me.Check1418 = True Then 
      Me.cmd_delete.Enabled = False  
    Me.Check1234.Enabled = False  
    Me.Check111.Enabled = False  
    Me.check116.Enabled = False  
    Me.cmd_save_record.Enabled = False  
    Me.enter_notes.Enabled = False 
      Else  
      Me.Check1234.Enabled = True  
    Me.Check111.Enabled.Enabled = True  
    Me.check116.Enabled = True  
    Me.cmd_delete.Enabled = True  
    Me.cmd_save_record.Enabled = True  
    Me.enter_notes.Enabled = True 
      End If  
    End Sub


  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Is this close?

    Code:
    Private Sub Form_Current()
       If Me.Check1212 = True Or Me.Check1418 = True Then
          'all are disabled
          Me.cmd_delete.Enabled = False
          Me.Check1234.Enabled = False
          Me.Check111.Enabled = False
          Me.check116.Enabled = False
          Me.cmd_save_record.Enabled = False
          Me.enter_notes.Enabled = False
       Else
          'these are enabled
          Me.cmd_delete.Enabled = True
          Me.cmd_save_record.Enabled = True
          Me.enter_notes.Enabled = True
    
          'now eval Check111  & Check1234
          If Me.Check111 = True And Me.Check1234 = True Then
             Me.Check1234.Enabled = False
             Me.Check111.Enabled = False
             Me.check116.Enabled = False
          Else
             Me.Check1234.Enabled = True
             Me.Check111.Enabled = True
             Me.check116.Enabled = True
          End If
       End If
    End Sub

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    That accomplishes what I am needing, but other than creating two different procedures what is the difference between the code you posted and what I was working with?

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    but other than creating two different procedures what is the difference between the code you posted and what I was working with?
    The only difference is where I put the logic for the check boxes "Check111 and Check1234".



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

Similar Threads

  1. What does this code mean
    By jo15765 in forum Programming
    Replies: 8
    Last Post: 12-08-2010, 01:05 PM
  2. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  3. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  4. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  5. Need help with code
    By hoenheim in forum Programming
    Replies: 9
    Last Post: 09-11-2008, 04:19 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