Check boxes

REDaughdril

Registered User.
Local time
Today, 10:49
Joined
Jan 23, 2000
Messages
58
I have a form that for simplicity has four boxes, left upper, right upper, left lower, right lower. Each box has a check box in it. I don't want to use the option group because I need to be able to check none, one two... or all boxes. If the boxes are checked it will send "text" to a field name [BoxLocation] ("left upper" or "right lower"). So theoretically in my table.BoxLocation I could have record 1 left upper, record 2 left lower..etc... I also need it to open an other popup form (called "popup"). To make things more difficult, I also need it to clear the text if the box is checked and then unchecked (if they make a mistake). I hope this is clear as mud. Thanks for the help.
 
Not sure I understand why you want to do this but the following code should do it for you.

It assumes the text is being written to BoxLocation in table "Check box info tbl".

Private Sub chkTL_Click()
CheckText = "Top Left"
ProcessInfo chkTL, CheckText
End Sub

Private Sub chkBL_Click()
CheckText = "Bottom Left"
ProcessInfo chkBL, CheckText
End Sub

Private Sub chkTR_Click()
CheckText = "Top Right"
ProcessInfo chkTR, CheckText
End Sub

Private Sub chkBR_Click()
CheckText = "Bottom Right"
ProcessInfo chkBR, CheckText
End Sub

Public Sub ProcessInfo(Switch As Boolean, CheckText As String)

Dim MyRst As DAO.Recordset
Set MyRst = CurrentDb.OpenRecordset("Check box info tbl", dbOpenDynaset)

With MyRst
If Switch Then
.AddNew
!BoxLocation = CheckText
.Update
Else
.FindFirst "[BoxLocation]='" & CheckText & "'"
.Delete
End If
End With

MyRst.Close

DoCmd.OpenForm "Popup"

End Sub
 

Users who are viewing this thread

Back
Top Bottom