Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Tables 1

Status
Not open for further replies.

ryan1

Programmer
May 15, 2002
106
US
Does anybody have any code handy to import tables by code. Or now were i can go to get it
 
SET UP:

1. Go to the Table tab click new and import table
2. Navigate to the table you want to import and click import
3. Within the import text wizard click on advanced in the bottom left corner
4. Here you can define how Access treats the data
5. When you are finnished click save as - remember the name you give it

CODE:

Function ImportDATA()
Dim sFileName As String

sFileName = "PUT THE PATH AND FILENAME HERE"

On Error GoTo ImportDATA_Err

'Import new data into import table
DoCmd.TransferText acImportFixed, "NAME YOU ASSIGNED IN SET UP", "TABLE NAME FOR IMPORT DATA", sFileName, False, ""

DoEvents

'Delete the file when the import is complete so you don't import it twice accidentally
Kill sFileName

DoCmd.SetWarnings True

MsgBox "Import Process Complete...", vbOKOnly, "Success !"

ImportDATA_Exit:
Exit Function

ImportHDDATA_Err:
Select Case Err
Case 3011
MsgBox "The file " & sFileName & " Does not exist...", vbExclamation, "Missing File ..."
Case Else
MsgBox Error$
End Select
Resume ImportDATA_Exit

End Function
 
Hey thanks, I give it a try this afternoon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top