Why won't this work?

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Why won't this work?

Post by Peter Kinross »

Where have I gone wrong?
This code should make 4 entries in a table, it only enters the first 2.
The Debug.? gives the correct results, they just don't get entered into the table.
I even tried transactions, but that made no diff.

Code: Select all

''Set Ws = DBEngine.Workspaces(0)
''Ws.BeginTrans
With rsOptIn
    .MoveFirst
    .Edit
    ![Dt] = StDate
    .Update
    .MoveNext
    For X = 0 To 2
        .Edit
        ![Dt] = DateAdd("yyyy", X, YrDate)
        Debug.Print X; DateAdd("yyyy", X, YrDate)
        .Update
        .MoveNext
    Next X
End With 'rsOptIn
''Ws.CommitTrans
Avagr8day, regards, Peter

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Why won't this work?

Post by Peter Kinross »

.AddNew instead of .Edit!
All working now.
Avagr8day, regards, Peter