Access MS Access 2007 : Form Yes/No

Joined
Jun 26, 2011
Messages
3
Reaction score
0
Hello Friends
I have created a simple database in access 2007.
A table in it contains YES/NO field.
I input data in that table through a FORM.
Now my problem is that some time I need to UN-CHECK (set NO) to all the cells (rows) of YES/NO field in form. I can do it manually one by one. But how can I UN-CHECK all by a single click, say by using a command button (using codes), etc.
Please help :(
 
The following VBA Code can do the trick for you:

Code:
Private Sub Command8_Click()
Dim rst As Recordset, bkmark As String
Set rst = Me.RecordsetClone
rst.MoveFirst
Do While Not rst.EOF
   bkmark = rst.Bookmark
   rst.Edit
   If rst![yesno] Then
      rst![yesno] = False
   ElseIf rst![yesno] = False Then
      rst![yesno] = True
   End If
   rst.Update
   
   Me.Bookmark = bkmark
   rst.MoveNext
Loop
rst.Close
Set rst = Nothing
   
End Sub
Change the Code for Command Button name and field name.
 
Thanks for your response
As per your advice, I pasted this code.
Error was shown at -
[FONT=&quot]
If rst![yesno] Then

I changed the name of field but again error ?????


Any way I solved it my self by creating an update query and running it with command button. That worked well.

Keep in touch.. Thanks again. :thumb:
[/FONT]
 
put this on close form event
and just list the check boxes


Private Sub Form_Close()
CurrentDb.Execute "Update Cases SET [name of check box1] = 0"
CurrentDb.Execute "Update Cases SET [name of check box2] = 0"
CurrentDb.Execute "Update Cases SET [name of check box3] = 0"
End Sub
 
Last edited:
Thanx for your response-
Update Query I made -
UPDATE (tblGroup INNER JOIN tblSubGroup ON tblGroup.IDGroup = tblSubGroup.IDGroup) INNER JOIN tblItem ON tblSubGroup.IDsubgroup = tblItem.IDsubgroup SET tblItem.[Select] = 0;

UPDATE (tblGroup INNER JOIN tblSubGroup ON tblGroup.IDGroup = tblSubGroup.IDGroup) INNER JOIN tblItem ON tblSubGroup.IDsubgroup = tblItem.IDsubgroup SET tblItem.[Select] = -1;
 
Back
Top