My skills are waning. Recordset says record deleted

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

My skills are waning. Recordset says record deleted

Post by Peter Kinross »

This won't work as trying to read the recordset values Nz(![Dt]) etc, shows the first line of the table to be deleted. It's not, it has 4 records, that I have just inserted. The records are there and visible when the recordset table is opened.
Obviously I am doing someting silly, but I have no idea what.

Code: Select all

With rsOptIn
    .MoveFirst
    Do Until .EOF
        S = Nz(![Dt]) & Tb & Nz(![AnFee]) & Tb & Nz(![FirstName]) & Tb & _
            Nz(![FullName]) & Tb & Nz(![treet]) & Tb & Nz(![Suburb]) & Tb & _
            Nz(![State]) & Tb & Nz(![Pcode]) & Lf
        appWD.Selection.InsertAfter S
        .MoveNext
    Loop
    appWD.ActiveDocument.Close , True
End With
Avagr8day, regards, Peter

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

Re: My skills are waning. Recordset says record deleted

Post by Peter Kinross »

I can get it to work by closing and re-opening the recordset just before the above code. But that workaround shouldn't be needed.
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: My skills are waning. Recordset says record deleted

Post by HansV »

Does it help if you change

Code: Select all

    Do Until .EOF
to

Code: Select all

    Do While Not .EOF
Best wishes,
Hans

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

Re: My skills are waning. Recordset says record deleted

Post by Peter Kinross »

It made no diff - unfortunately.
However the 'Do While Not' seems a bit more accurate, so I left it in.
This is to streamline a doc I would need about 50 times once a year. As it is working OK now it is not worth spending any more time on.
But thanks anyway Hans.
Avagr8day, regards, Peter