Results 1 to 10 of 10
  1. #1
    Cablenm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5

    Help with message box

    Thanks in advance for any help.



    I have a form that has 8 yes/no check boxes on it. I have a combo box that has several choices, one of them being "Complete". I would like to have a message box pop up if the user chooses "Complete" if any or all check boxes are checked. Then when they hit ok to close the message box, the combo box reverts back to the what it was. If all check boxes are unchecked then no message box appears and it just allows the combo box change to "Complete" happen.

    Can anyone help me with how to code this??

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If the CheckBoxes are bound to fields in the RecordSource then code in the AfterUpdate event of the ComboBox could easily accomplish what you want.

  3. #3
    Cablenm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5
    That would be great except I don't no how to go about coding it. Kind of brain dead in that department. Any help would be greatly appreciated.

    And yes, they are bound to the record source.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This should get you started but you will need to change the RED items to your names.
    Code:
    Private Sub cbo_AfterUpdate()
       Dim IsChecked As Boolean      '-- Defaults to False
       Dim ctl As Control
     
       For Each ctl In Me.Controls
          If ctl.ControlType = acCheckBox Then
             If ctl = True Then
                IsChecked = True
             End If
       Next ctl
       If IsChecked Then
          MsgBox "Here's a message for you"
          Me.cbo.Undo
       End If
     
    End Sub
    This also assumes the ComboBox is bound as well.

  5. #5
    Cablenm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5
    Quote Originally Posted by RuralGuy View Post
    This should get you started but you will need to change the RED items to your names.
    Code:
    Private Sub Combo30_AfterUpdate()
       Dim IsChecked As Boolean      '-- Defaults to False
       Dim ctl As Control
     
       For Each ctl In Me.Controls
          If ctl.ControlType = acCheckBox Then
             If ctl = True Then
                IsChecked = True
             End If
       Next ctl
       If IsChecked Then
          MsgBox "Here's a message for you"
          Me.Combo30.Undo
       End If
     
    End Sub
    This also assumes the ComboBox is bound as well.

    I inserted the combo box name that is bound. I get a complie error "Next without For".

    Does your code cover all 8 check boxes, or do they need listed separate?

    Also, the message box should only come up if "Completed" is choosen in the combo box. I hope this makes sense.

    Really appreciate your time here!!!!!!!!!!!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Oops! Air code has its problems:
    Code:
    Private Sub Combo30_AfterUpdate()
       If Me.Combo30 = "Completed" Then
          Dim IsChecked As Boolean   '-- Defaults to False
          Dim ctl As Control
          For Each ctl In Me.Controls
             If ctl.ControlType = acCheckBox Then
                If ctl = True Then
                   IsChecked = True
                End If
             End If
          Next ctl
          If IsChecked Then
             MsgBox "Here's a message for you"
             Me.Combo30.Undo
          End If
       End If
    End Sub

  7. #7
    Cablenm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5
    ***You are great. The only problem is it would not change the "completed" back to what ever it was prior, it just stayed "Completed". I made the change you see and that works for now. Any Ideas?

    Quote Originally Posted by RuralGuy View Post
    Oops! Air code has its problems:
    Code:
    Private Sub Combo30_AfterUpdate()
       If Me.Combo30 = "Completed" Then
          Dim IsChecked As Boolean   '-- Defaults to False
          Dim ctl As Control
          For Each ctl In Me.Controls
             If ctl.ControlType = acCheckBox Then
                If ctl = True Then
                   IsChecked = True
                End If
             End If
          Next ctl
          If IsChecked Then
             MsgBox "Here's a message for you"
             Me.Combo30 = "Work In Progress"
          End If
       End If
    End Sub

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Does the ComboBox have a ControlSource?

  9. #9
    Cablenm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    5
    Yes "Statis ID"

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    In that case the Me.Combo30.UnDo should have worked.

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

Similar Threads

  1. Message Box
    By BorisGomel in forum Programming
    Replies: 6
    Last Post: 04-25-2011, 02:16 PM
  2. Message Box
    By dunnmel4 in forum Programming
    Replies: 9
    Last Post: 04-12-2011, 10:44 PM
  3. Message Box question
    By bullwinkle55423 in forum Programming
    Replies: 1
    Last Post: 08-12-2010, 09:01 AM
  4. Message box issues.
    By thart21 in forum Programming
    Replies: 2
    Last Post: 05-29-2010, 12:58 AM
  5. message box help
    By shaz10010 in forum Forms
    Replies: 1
    Last Post: 04-17-2009, 09:11 AM

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