Help with code needed: Import records from Excel CSV file

D

DetRich

Hello All,

Upon click of a command button, I need to import from an Excel CSV file.
Ideally, I'd like to display the record and decide, Yes or No whether or not
to import the record into an existing table. The table has many more columns
than does the CSV file. I have no idea what the code behind the command
button should be and that is what I am asking for help with. I think I need
to:

1. Open a Open File dialog box to navigate to the CSV file.
2. Open the selected file.
File will have 1st row being column titles/headers.
When reading the file, it does not matter to me if we read the entire file
or record by record. File is likely 10K or less, with less than 100 rows & 7
columns.
3. Display the first record.
4. Keep record, Yes or No.
5. If keep record, then
import it to the table
Else
Drop record, move to next record.
End If

If reading the entire file at once, good idea would be to display all
records in a grid and have a simple Y/N checkbox as to whether to keep it or
not.

I know that's a lot to ask, but I've never done any Access when reading
other files.

TIA,
Rich
 
S

Stuart McCall

DetRich said:
Hello All,

Upon click of a command button, I need to import from an Excel CSV file.
Ideally, I'd like to display the record and decide, Yes or No whether or
not
to import the record into an existing table. The table has many more
columns
than does the CSV file. I have no idea what the code behind the command
button should be and that is what I am asking for help with. I think I
need
to:

1. Open a Open File dialog box to navigate to the CSV file.
2. Open the selected file.
File will have 1st row being column titles/headers.
When reading the file, it does not matter to me if we read the entire file
or record by record. File is likely 10K or less, with less than 100 rows
& 7
columns.
3. Display the first record.
4. Keep record, Yes or No.
5. If keep record, then
import it to the table
Else
Drop record, move to next record.
End If

If reading the entire file at once, good idea would be to display all
records in a grid and have a simple Y/N checkbox as to whether to keep it
or
not.

I know that's a lot to ask, but I've never done any Access when reading
other files.

TIA,
Rich

You really need to be aware that you can link to csv files just like any
other database file. Then you can accomplish the selection easily (it's just
another table so you can read & manipulate data as usual).

When you see the file selection dialog for linking tables, drop down the
'Files of Type' combo at the bottom of the dialog, and select 'CSV Files'.
Select your csv file, click Ok (or Link) and you will have a new linked
table to play with.

Hope that helps
 

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

Top