S
Santiago Gomez
I would like to automatically update all records on a table based on what
the user enters in a form.
Table1
Name
Sex
Courses
on the form, when a user enters a number on txtCourse, I want to open the
table, go through each record, and insert the same number on all of them.
Furthermore, I want the code to be reusable, as I have 5 of these instances,
all going to different tables. If I name the control the same as the table,
would that help? then I can just pass the control name and insert it into
the sql command.
Please help.
this is what I have so far but I dont know how to update the record...
Private Sub UpdateTable(sTableName As String, dblValue As Double)
Dim rstnew As Recordset
Set rstnew = CurrentDb.OpenRecordset("select * from " & sTableName)
rstnew.MoveFirst
Do Until rstnew.EOF
rstnew.Update
? For Each Row In rstnew
? .Value = dblValue
? Next Row
rstnew.MoveNext
Loop
End Sub
the user enters in a form.
Table1
Name
Sex
Courses
on the form, when a user enters a number on txtCourse, I want to open the
table, go through each record, and insert the same number on all of them.
Furthermore, I want the code to be reusable, as I have 5 of these instances,
all going to different tables. If I name the control the same as the table,
would that help? then I can just pass the control name and insert it into
the sql command.
Please help.
this is what I have so far but I dont know how to update the record...
Private Sub UpdateTable(sTableName As String, dblValue As Double)
Dim rstnew As Recordset
Set rstnew = CurrentDb.OpenRecordset("select * from " & sTableName)
rstnew.MoveFirst
Do Until rstnew.EOF
rstnew.Update
? For Each Row In rstnew
? .Value = dblValue
? Next Row
rstnew.MoveNext
Loop
End Sub