Check all

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to check all check boxes with the click of one check
box, this is on a continuous form and will append the table on a global
scale. Thanks in advance.
 
Assuming the CheckBoxes are bound to a field in the RecordSource for the
continuous form then an update query would be my tool of choice.
 
Ok, I have

Private Sub Command22_Click()
Me.Oustanding = 0

End Sub

But how do you get it to go to the next record and stop at the end of the
record set?
 
Stacey, as RuralGuy mentioned, you need to use an Update Query...

If you want to set all check box fields (Yes/No) to True in a table then try
something like this in your Click event:

Dim strSQL As String
strSQL = "UPDATE myTable SET myField = " & True

CurrentDb.Execute strSQL, dbFailOnError

Change myTable and myField to the name of the respective table and field name.

Steve
 
Steve has given you the code for the update query but you will need to
requery so your form will pick up the changes.
 
Does anyone know how to check all check boxes with the click of one check
box, this is on a continuous form and will append the table on a global
scale. Thanks in advance.

Run an Update query to update the table's Yes/No field to True (-1), using
whatever criteria would update the desired records.

The data isn't stored on the form, and it isn't stored in a checkbox; it's
stored in the table as -1 for Yes/True/checked, 0 for No/False/unchecked. It's
the table that you need to update, not the form!

John W. Vinson [MVP]
 
ok this is what I have..

Private Sub Command22_Click()
Dim strSQL As String
strSQL = "UPDATE Forecastnames SET Oustanding = " & -1
CurrentDb.Execute strSQL, dbFailOnError
End Sub

one problem....why does the form not update (only the first checkbox) until
I close and reopen the form?
 
Ruralguy and John, i do like your idea of using the update query, however I
do not want users of the db to keep seeing that pop up warning message that
items in the table are about to change.

Douglas, I tried adding me.requery and me.refresh....they both don't work
very well, any other suggestions?
 
Guys I got it me.requery did work, I just had to put before

CurrentDb.Execute strSQL, dbFailOnError

Thanks everyone for all of your help!! =)
 
Ruralguy and John, i do like your idea of using the update query, however I
do not want users of the db to keep seeing that pop up warning message that
items in the table are about to change.

Douglas, I tried adding me.requery and me.refresh....they both don't work
very well, any other suggestions?


As I know, CurrentDb.Execute don't ask for confirmation? In any other
cases you can add before code

DoCmd.SetWarnings False

and after

DoCmd.SetWarnings True

and appropriate Error capturing code in case when Update query fails,
but this is not a case here.

For example, following will ask for confirmation:

Private Sub Command22_Click()
Dim strSQL As String
strSQL = "UPDATE Forecastnames SET Oustanding = " & -1
DoCmd.RunSQL strSQL
End Sub

If you see message "Save Record" or "Drop Changes" that suggest that
someone else (even you) is making changes to the same record at the
same time when Update query do. As program does not know to whom to
give priority and which one to discard it ask you to decide.

I am just guessing as your description is not completed.

Regards,
Branislav Mihaljev
 
Back
Top