Hello Everyone!

jumadenice

New member
Local time
Today, 12:02
Joined
Jun 29, 2010
Messages
3
Editiing and updating an access table

I am using the code below to update an table called Details_master with data from a table called details on the click event of a command button

Option Compare Database

Private Sub Command0_Click()

Dim db As Database
Dim rs As Recordset
Dim rs1 As Recordset
Dim NR

Set db = CurrentDb
Set rs = db.OpenRecordset("Details_master")
Set rs1 = db.OpenRecordset("details")
If [rs].RecordCount > 0 Then
NR = [rs].RecordCount

For I = 1 To NR
[rs].MoveFirst


With rs
'If [rs]![id] = [rs1]![id] Then
'.AddNew
.Edit
![id] = [rs1]![id]
![Name] = [rs1]![Name]
![name2] = [rs1]![name2]
![name3] = [rs1]![name3]
![Date] = [rs1]![Date]
.Update
.MoveNext
'End If
End With



Next I
End If


[rs].Close

Set rs = Nothing
Set rs1 = Nothing
MsgBox "The record was successfully updated"

End Sub


After running the code, It only updates the first record on the table. It does not loop through the existing records on the Details_master table

Assist in correcting it
 
Last edited:

Users who are viewing this thread

Back
Top Bottom