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 Access > mandatory checkbox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-19-12, 12:04
pirseinkim pirseinkim is offline
Registered User
 
Join Date: May 2012
Posts: 3
mandatory checkbox

I have a checkbox on my main form. This checkbox is to be mandatory on save and close. If this checkbox has not been checked then an error message is supplied and it goes to the field I assigned to setfocus. This does work on save. However if I go to close and the checkbox hasn't been checked then it will supply the error message then close. Does not go to the designated setfocus field. You can't setfocus to a checkbox right?

Thanks in advance
Kim P
Reply With Quote
  #2 (permalink)  
Old 07-19-12, 17:17
Missinglinq Missinglinq is offline
Registered User
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,213
I'm confused! What is the point of having a Checkbox Control that has to have one and only one given Value, i.e has to be equal to True/Yes/-1, before the Record can be saved?

That aside, you have to Cancel the save before returning Focus to the Checkbox. in general terms, Validation code to check Controls before saving a Record should be something like this:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

 If Me.CheckboxName <> -1 Then
   MsgBox "CheckboxName Must Be Ticked Before Saving Record!"
   Cancel = True
   CheckboxName.SetFocus
   Exit Sub
 End If
 
End Sub
Linq ;0)>
__________________
Hope this helps!

The Devil's in the Details!!

All posts/responses based on Access 2003/2007
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On