I have a CSV delimited file with row data that I want to transfer to MS Access columns. MS Access is already open; I have a button on Access form to import Excel to the table. For instance, In the CSV file cell b1 and b2 have this data:
JPWestfield
8/1/2019
Customer and date are columns in Access. I want to add excel CSV data to MS Access table as column data:
Customer Date
JPWestfield 8/1/2019
I am looking for VBA Code to do this. I saw this so far, but I think its for Excel and not CSV delimited.
I want to transfer B1 value to Customer and B2 value to Date column in Access. Not sure how to do this. I've found snippets of what I am looking for and so far I have this:
with rs
.AddNew
' add values to each field in the record
.Fields("Customer") = wks.Range("B1").Value
.Fields("Date") = wks.Range("B2").Value
End With
r = r + 1 next row
Loop
rs.Close
db.Close
Since Access is already open not sure if i should open it again. Also I think this may be code for Excel. The vba should be code for CSV delimited file.
2nd option I was thinking is to do a straight transfer dump of CSV to Access into a temp table. Then transfer the data from AccessTempTable to Another Access table field by field into the column format. Not sure how that would work since the data would be in row format in the AccessTempTable.
Your help is appreciated.
Thanks,
Ben
JPWestfield
8/1/2019
Customer and date are columns in Access. I want to add excel CSV data to MS Access table as column data:
Customer Date
JPWestfield 8/1/2019
I am looking for VBA Code to do this. I saw this so far, but I think its for Excel and not CSV delimited.
I want to transfer B1 value to Customer and B2 value to Date column in Access. Not sure how to do this. I've found snippets of what I am looking for and so far I have this:
with rs
.AddNew
' add values to each field in the record
.Fields("Customer") = wks.Range("B1").Value
.Fields("Date") = wks.Range("B2").Value
End With
r = r + 1 next row
Loop
rs.Close
db.Close
Since Access is already open not sure if i should open it again. Also I think this may be code for Excel. The vba should be code for CSV delimited file.
2nd option I was thinking is to do a straight transfer dump of CSV to Access into a temp table. Then transfer the data from AccessTempTable to Another Access table field by field into the column format. Not sure how that would work since the data would be in row format in the AccessTempTable.
Your help is appreciated.
Thanks,
Ben