DJRave


Hey there,

I've written the following script to copy certain fields from a table (column) to another table (row). It does what I want but it contains a bug that I can't solve. After copying al the fields it generates a run-time error: "3021 No current record" on the yellow line in my example code.

Can somebody help me solve this bug

Thanks a lot

Public Sub ImportLogging()

Dim db As Database
Dim rec_source As Recordset
Dim rec_destin As Recordset

Set db = CurrentDb
Set rec_source = db.OpenRecordset("select * FROM source", dbOpenDynaset)

Set rec_destin = db.OpenRecordset("select * from destination", dbOpenDynaset)

Do While Not rec_source.EOF

rec_destin.AddNew

If rec_source![Prefix] = ("H1") Then
rec_destin![FileID] = rec_source![Column2]
End If
rec_source.MoveNext

If rec_source![Prefix] = ("H2") Then
rec_destin![Rapportagedatum] = rec_source![Column2]
End If
rec_source.MoveNext

If rec_source![Prefix] = ("H3") Then
rec_destin![EANcodeVerzender] = rec_source![Column2]
End If
rec_source.MoveNext

If rec_source![Prefix] = ("H4") Then
rec_destin![EANcodeOntvanger] = rec_source![Column2]
End If
rec_source.MoveNext

If rec_source![Prefix] = ("H5") Then
rec_destin![Productsoort] = rec_source![Column2]
End If
rec_source.MoveNext

If rec_source![Prefix] = ("H6") Then
rec_destin![Marktrol] = rec_source![Column2]
End If
rec_source.MoveNext

If rec_source![Prefix] = ("H7") Then
rec_destin![Bestandsversie] = rec_source![Column2]
End If

Do
rec_source.MoveNext

Loop Until rec_source![Prefix] = ("F1")

If rec_source![Prefix] = ("1") Then
rec_destin![AantalRecords] = rec_source![Column2]
End If

rec_destin![ImportDatum] = Date

rec_destin.Update

rec_source.MoveNext

Loop

rec_destin.Close
rec_source.Close
db.Close

End Sub