Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a suggestion on marking all checkboxes true

Status
Not open for further replies.

RBE

Programmer
May 25, 2000
72
US
On my tables I have a checkbox control called [closed]. I need a way to automaticly check all the boxes pulled in a query. What this does is lock the record so that it cannot be changed. I am not very good a looping through sets of records and changing the value. In fact I am not sure how to pull a recordset at all in VB. I am pretty sure this needs to be done in VB or a query but how do I change records values in a query? Or how do a pull a record set and loop through it and change the values of this one field? The table name is [tenders] and the field name is [closed]. If some one could give me a loop recordset code to pull and change the value of [closed] to true I sure would appreicate it. I have tryed a button on a form but it will only change the active record not all the records.
Here is the code I have on

Private Sub Command1_Click()
Dim ctl As Control
Do Until Me.[closed] = True
For Each ctl In Me.Form
If [closed].Value = False Then
[closed].Value = True
End If
Next ctl
Loop
End Sub

You can always say tomarrow, but when you say yesterday, today is easier.

RBE

Our prayers go out to the WTC victims
 
Never mind I can't belive I didn't think of this before. Just for future reference "run an update query to true"

duh!!!

Sorry for bothering you all with something this stupid.
You can always say tomarrow, but when you say yesterday, today is easier.

RBE

Our prayers go out to the WTC victims
 
This should work for you.

Dim DB As Database
Dim Qdf As QueryDef
Set DB = CurrentDb
Set Qdf = DB.CreateQueryDef("", "UPDATE tenders SET closed = True")
Qdf.Execute The hardest questions always have the easiest answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top