Updating several records at once

toddbingham

Registered User.
Local time
Today, 03:40
Joined
Jul 8, 2003
Messages
93
Need to update several humdred records at once, would like to have an easy way of doing that witha select all check box or something like that. Look at the attachmentto see wha I have.
 

Attachments

An Update query will do what you want. Search Access help for more details on Update Queries...

hth,
Jack
 
In the OnClick of the check box use:

Code:
Dim db As Database
Dim rs as RecordSet
Dim rCount as Integer
Dim cnt as Integer
rCount = 0

Set db = CurrentDB();
Set rs = db.OpenRecordSet("Table")

rs.MoveLast
rCount = rs.RecordCount
rs.MoveFirst

Do Until rs.EOF
   rs.Fields("Checkboxfield") =  checkbox.value
   rs.update
loop

Don't know if it works or not. Time to go home so let me know and I will work on it tomorrow.


for
 
Here is my code. Get a compile error.

Dim db As Database
Dim rs As Recordset
Dim rCount As Integer
Dim cnt As Integer
rCount = 0

Set db = "Printed Checks"();
Set rs = db.OpenRecordset("Table")

rs.MoveLast
rCount = rs.RecordCount
rs.MoveFirst

Do Until rs.EOF
rs.Fields("Checkboxfield") = CheckBox.Value
rs.Update
Loop


Get an Expected End of Statement on this Line:
Set db = Printed Checks();

What seems to be the problem?
 
Todd,

Code:
Dim db As Database 
Dim rs As Recordset 
Dim rCount As Integer 
Dim cnt As Integer 
rCount = 0 

Set db = CurrentDb   ' What is "Printed Checks"();  Your Db?
Set rs = db.OpenRecordset("Table") 

rs.MoveLast 
rCount = rs.RecordCount 
rs.MoveFirst 

Do Until rs.EOF 
   rs.Edit
   rs.Fields("Checkboxfield") = CheckBox.Value 
   rs.Update 
   rs.MoveNext
   Loop

Wayne
 
heh. Sorry for misleading you with the ;. I was programming in C++ when I posted it.
 
Now I get an error that says invalid outside procedure. I have tried both putting it on the click properties of the check bow like:
Private Sub Check14_Click()

Dim db As Database
Dim rs As Recordset
Dim rCount As Integer
Dim cnt As Integer
rCount = 0

Set db = CurrentDb
Set rs = db.OpenRecordset("Table")

rs.MoveLast
rCount = rs.RecordCount
rs.MoveFirst

Do Until rs.EOF
rs.Edit
rs.Fields("Check14") = CheckBox.Value
rs.Update
rs.MoveNext
Loop
End Sub

And in the declarations part of the code. What should I do?
 
Should have brackets at the end of your set statement.

Set db = CurrentDB()

Like that
 
rs.Fields("Check14") = CheckBox.Value

is Check14 the field name in the database or the name of a check box.

It mus be the field name in the table.
 

Users who are viewing this thread

Back
Top Bottom