If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Check box error message

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-12, 05:55
JohnMc JohnMc is offline
Registered User
 
Join Date: Nov 2011
Posts: 12
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.
Reply With Quote
  #2 (permalink)  
Old 02-10-12, 15:36
dave0810471 dave0810471 is offline
Registered User
 
Join Date: Jan 2012
Posts: 87
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
File Type: zip Book1.zip (9.5 KB, 5 views)
Reply With Quote
  #3 (permalink)  
Old 02-14-12, 05:32
JohnMc JohnMc is offline
Registered User
 
Join Date: Nov 2011
Posts: 12
Dave,

thanks for the reply but the zip was empty !

Regards

John Mc
Reply With Quote
  #4 (permalink)  
Old 02-14-12, 05:57
dave0810471 dave0810471 is offline
Registered User
 
Join Date: Jan 2012
Posts: 87
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
Reply With Quote
  #5 (permalink)  
Old 03-15-12, 10:25
JohnMc JohnMc is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 03-15-12, 16:16
dave0810471 dave0810471 is offline
Registered User
 
Join Date: Jan 2012
Posts: 87
Your welcome.
__________________
Hope this helps,

Dave.

_____________

Access 2000 User
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On