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 :(
 
Joined
Jul 20, 2011
Messages
16
Reaction score
0
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.
 
Joined
Jun 26, 2011
Messages
3
Reaction score
0
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]
 
Joined
Aug 16, 2011
Messages
2
Reaction score
0
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:
Joined
Jun 26, 2011
Messages
3
Reaction score
0
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top