Updating a recordset

  • Thread starter Thread starter Allie
  • Start date Start date
A

Allie

I have data going to a second table (tableB) when a
particular criteria is met. I can add data using the
recordset Addnew method, I can delete data but I can not
update the data using the Edit method.

I am using Acc97 and DAO 3.51.

Here is the code I am using:

Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tableB", dbOpenDynaset)
With rs
Edit
.Fields("BkID") = Me.ID
.Fields("User") = Me.User
.Fields("StateNo") = Me.StateNo
.Fields("Amount") = Me.Amount
.Fields("DateEntered") = Me.Date
.Fields("EnteredBy") = CurrentUser()
.Update
.Close
End With

I've tried using the MoveNext and Find and seek methods
with no luck.

Please help

Thanks
 
Allie said:
I have data going to a second table (tableB) when a
particular criteria is met. I can add data using the
recordset Addnew method, I can delete data but I can not
update the data using the Edit method.

I am using Acc97 and DAO 3.51.

Here is the code I am using:

Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tableB", dbOpenDynaset)
With rs
Edit
.Fields("BkID") = Me.ID
.Fields("User") = Me.User
.Fields("StateNo") = Me.StateNo
.Fields("Amount") = Me.Amount
.Fields("DateEntered") = Me.Date
.Fields("EnteredBy") = CurrentUser()
.Update
.Close
End With

I've tried using the MoveNext and Find and seek methods
with no luck.

Please help

Thanks

First, if that's a direct quote from your code, it can't work because you
don't have the dot (.) in front of your call to the Edit method. Instead of

you'd need to have

.Edit

Second, what record are you editing here? If the table is empty, you can't
..Edit, you have no choice but to .AddNew. If the table is not empty, this
(corrected) code is always going to update the first record returned in the
recordset. Is that what you want?
 
Back
Top