schema.ini

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In MS Access I am creating a project(.adp). I want to be able to transfer
text from a cd-rom drive to my access database as a table.

I have created my code as follows:

Private Sub Command1_Click()

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
DoCmd.TransferText acImportDelim, "", "tblEubdata" & Format(Date, "yyyy"),
strInputFileName, True, ""

End Sub

Now this works fine as long as I copy the file from d: to c: and alter my
schema.ini file to be the same as the file I just copied from d.

Question: Is there a way to automate this to just be able to select the
file I want to transfer and have it copy to my c: drive and alter my
schema.ini?? The way I understand it the text file and the schema.ini have
to be in the same directory and that the schema.ini filename must match that
of the text file.

Any ideas??
 
You could use the FileCopy() statement to copy the file to a standard
name and location on your C: drive. E.g. something like this air code:

...
Dim strTempFolder As String
Const TEMP_FILE_NAME = "$$$DB_Import_$$$.txt"

...
'Get location of user's Temp folder
strTempFile = Environ("TEMP") & "\" & TEMP_FILE_NAME
'Delete old file if it exists
Kill strTempFile
FileCopy strInputFileName, strTempFile
DoCmd.TransferText blah strTempFile blah
...
 
Back
Top