Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2011
    Posts
    12

    Unanswered: Check box error message

    Hi,

    I'm playing around with checkboxes for the first time and dipping my toes into VBA and really could do with a little help from those with a far better understanding than me.

    I've got a check box in one cell (checkbox1) and I also have another cell (we'll say "D10") and what I am trying to do is link an error message box to appear when the checkbox is selected and if the cell contains either a 1 or 7 (Sunday, Saturday).

    The idea being that if someone clicks on the check box and the Weekday in cell "D10" is either a Saturday or Sunday a message box appears and warns them that they've selected a weekend day (which they can do in certain circumstances but need the error message to warn them of the fact)

    Any help gratefully received.

  2. #2
    Join Date
    Jan 2012
    Posts
    97
    JohnMc,

    Please see attached excel file that will check for your conditions. I'm not 100% sure what you mean by error message, an error message is a static message that informs the user of something. An alternative would be to prompt the user for an action (i.e. to confirm data entry that violates expected conditions) this way you can guarantee your data is valid.

    Hope this helps,

    Dave
    Attached Files Attached Files

  3. #3
    Join Date
    Nov 2011
    Posts
    12
    Dave,

    thanks for the reply but the zip was empty !

    Regards

    John Mc

  4. #4
    Join Date
    Jan 2012
    Posts
    97
    John Mc,

    Strange, I was able to download the file. Never mind - simply assign the following macro to a checkbox assigned to cell A1 and enter your numerical value in D10.

    Code:
    If [A1] = True Then
    MsgBox ("Checked")
    'if the check box is checked then enter the select case
    Select Case Range("D10").Value
    Case 1 'if the number in D10 = 1 then run the following code
    MsgBox ("good 1")
    Case 7 'if the number in D10 = 7 then run the following code
    MsgBox ("good 7")
    Case Else 'if the number in D10 <> 1 or 7 then run the following code
    MsgBox ("Checked but not met")
    End Select
    Else
    'if the check box is NOT checked then run the following code
    MsgBox ("Not checked")
    End If
    Hope this helps,

    Dave.

    _____________

    Access 2000 User

  5. #5
    Join Date
    Nov 2011
    Posts
    12

    Thumbs up Many Thanks

    Dave,

    I know my reply has took a while but many thanks that code was 100% - thanks again

  6. #6
    Join Date
    Jan 2012
    Posts
    97
    Your welcome.
    Hope this helps,

    Dave.

    _____________

    Access 2000 User

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •