Re: Updating a recordset
From: Dirk Goldgar (dg_at_NOdataSPAMgnostics.com)
Date: 08/14/04
- Next message: MikeC: "AfterDelete Event Wanted"
- Previous message: Duane Hookom: "Re: SQL Statement and Microsoft Access Query"
- In reply to: Allie: "Updating a recordset"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 14 Aug 2004 00:05:19 -0400
"Allie" <anonymous@discussions.microsoft.com> wrote in message
news:5da801c48156$d2bed9b0$a601280a@phx.gbl...
> 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
> Edit
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?
-- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup, not by e-mail)
- Next message: MikeC: "AfterDelete Event Wanted"
- Previous message: Duane Hookom: "Re: SQL Statement and Microsoft Access Query"
- In reply to: Allie: "Updating a recordset"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|