Copy current record from recordset to csv

Mindgem

New member
Local time
Today, 07:55
Joined
Aug 4, 2013
Messages
2
Hi,

I have a DAO.recordset called "rsSQLIn". This comes from a csv file by:

Code:
strSql = "SELECT * " _
                & "FROM [Text;Database=" _
                & strFolder _
                & ";HDR=No;FMT=CSVDelimited;].[" _
                & FileNamea _
                & "]"

FileNamea is an .ini file that is generated automatically.

This works fine.
I validate this input by the access table which this result should go to.
The method I do this by is:

Code:
Set tdf = dbs.TableDefs("tbl_import_bk")
 
Do While Not rsSQLIn.EOF
 
rsSQLOut.AddNew
 
                            For Each fld In tdf.Fields

And so on.
While the validation runs a boolean keeps track of validated input and errored input.

After validation the validated input is dumped in the table.

Now what I want is de saving the errored record from "rsSQLIn" to be copied to a new .csv file.

The problem I have is that I cant seem to get the current record from the recordset "rsSQLIn". How do I reference this? I need the complete set of 24 fields being the same within "rsSQLIn"
 
If I understand you, you want to write validated data to tbl_import_bk and any records not passing the validation test are to be exported to a CSV file.

If so, the easiest would be to write such records to another table, say tbl_import_errors, then export the records in this table to your CSV file. Of course, you empty this table before the import process starts.
 
Oke I will try if my current solution fails which Im trying to create now.

In the loop where the fields are validated I let a appending string build up with the variables from rsSQLIn. When, after all fields are validated of the record, and validation has failed then this string will be exported to a .csv

Have current problems with the building of the string (am new to VBA / used php in the past), but it must be a small thing that is the cause of the problem. Will adress it tomorrow.

Thanks for the suggestion!
 
I didn't mention anything about appending strings in a loop. Read my post carefully.
 

Users who are viewing this thread

Back
Top Bottom