We help IT Professionals succeed at work.

Importing a CSV file in my database

Biggles1
Biggles1 asked
on
107 Views
Last Modified: 2018-12-14
I use the following code to import a csv file into my database:

Private Sub cmdImport_Click()
On Error GoTo Err_cmdImport_Click:
Dim dbs As Database
Dim strSQL As String

DoCmd.SetWarnings False

Set dbs = CurrentDb

DoCmd.TransferText acExportDelim, "DelimWO-1", "tblImported", "C:\Users\AllPC\Downloads\Service-requests-08-22-18"

Exit Sub
Err_cmdImport_Click:
MsgBox Err & " " & Err.Description
End Sub

The table tblImported is already created (otherwise I get an error that it cant find it!)

When I run the program I get: 3027 Cannot Update.  Database Object is Read-Only.  I tested the table tblImported and it is NOT read-only

Any ideas?
Comment
Watch Question

Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
TransferText with the acExportDelim argument will EXPORT your data, not IMPORT it. Your expression would export data from a table named tblImported to a file at the address in that last argument (which is not properly formed - you should have a filename at the end).
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Biggles1Founder/CEO

Author

Commented:
I realize my typo: It should have been acImportDelim
Biggles1Founder/CEO

Author

Commented:
Jo Winograd gave me some extensive answers.  Now I cant find them!  Please help.
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
I'm not sure how we can help with this.  If you look in your profile, you should be able to see all the questions you asked.  Where the answers in some question you asked?  If not, try pinging Jo but ypu'll have to provide more detail since I'm sure she answers lots of questions.

New questions should be started in new threads.