Update several records at the same time
I need to update several records at the same time.
I used
for i = 0 to 3
rs("name") = UCase(Trim(txtName(i).Text))
rs("age") = UCase(Trim(txtAge(i).Text))
rs("preference") = txtPref
rs.Update
next i
It failed to work :
"Method of update of object recordset failed"
Can anyone help me?
Re: Update several records at the same time
Hi
If u use the Update Method, U will have to use
either Addnew or Edit method.
The code should look like
for i = 0 to 3
rs.Addnew ( or ) rs.Edit
rs("name") = UCase(Trim(txtName(i).Text))
rs("age") = UCase(Trim(txtAge(i).Text))
rs("preference") = txtPref
rs.Update
next i
All the best
Bye Bye take Care
Vijooo
Re: Update several records at the same time
...and use edit to modify existing records. Use addnew to create a new record. Do not forget to rate Vijoo if he helped you.
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
Re: Update several records at the same time
Vijooo, I have tried what you have suggested, but there is no Edit method !!!
I can only find EditMode method instead.
When I used rs.EditMode, it prompted an error "Invalid use of property".
What's wrong ???
Please help me
Re: Update several records at the same time
Edit exists only for DAO, for ADO you don't have to use rs.Edit
Iouri Boutchkine
[email protected]
Re: Update several records at the same time
HI
If u r using ADO, then u wont be having the
Edit Method. If u r working with DAO then it
can be used.
Anyway , Idf u want to edit a Particular record
Then use the Execute Method with SQL Query.
Sql query will look like this.
For Edit
Update [Table Name] Set [Field Name] = Values
Where Condition.
For Addition
Insert Into [Table Name] ( values )
Make the queries to execute in Execute Method.
This is the best way to work with ADO.
Mail me back about the status.
All the best
Take Care Bye Bye
Vijooo