importing data



It has been quiet a while (several years) since I did some programing in VBA. I was and still am a newbee in VBA.
So would someone be so kind to help me with this one.

Beneath I put some code which imports some csv data into an access table. For years it worked in Access 2003. But now we moved tot Access 2011 and data doesn't fit anymore in the appropriate field. I get a series of comma delimited data in 1 field, another comma delimited data into another etc.

Some I suppose I have to ad some extra code in order to get rid of this andput every separate data into the right consecutive field.

info: 'TBL_field_names' serves as to give each field in my table a new nameand changes the imported old name into a new fieldname.

I hope I made myself understandable.


Private Sub Command81_Click()
Dim rst_data As Recordset
Dim oldname As String, newname As String
DoCmd.DeleteObject acTable, "TBL_import_TPXP_Radi_Evvd"
DoCmd.TransferText acImportDelim, , "TBL_import_TPXP_Radi_Evvd", "N:\APPLSHARE\PRD\QSIG\MKTDISTPWB\USPB1815\RADIEV\IMPACT.CSV", False, ""

Set rst_data = CurrentDb.OpenRecordset("TBL_field_names")

With rst_data
Do Until .EOF
oldname = .Fields(0).Value
newname = .Fields(1).Value
changefieldnames oldname, newname
End With
Set rst_data = Nothing

'DoCmd.RunSQL "ALTER TABLE [TBL_import_TPXP_Radi_Evvd] ALTER COLUMN [Ontlener] text"
'DoCmd.RunSQL "UPDATE TBL_import_TPXP_Radi_Evvd SET TBL_import_TPXP_Radi_Evvd.Ontlener = Right('000000000000' & [TBL_import_TPXP_Radi_Evvd]![Ontlener],12);"
Jun 6, 2014
Reaction score
Did u try recording a Macro while manual processing? If we do this, we will get an equivalent code in VBA for importing data. After that, we can manually edit the VBA to our need.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question