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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending dbase file to Access table with code 1

Status
Not open for further replies.

chatfield

Technical User
May 4, 2001
8
US
I am developing an application for a client that will, among other things, have him append a dbase file that is on a diskette in drive A to a table residing in an Access database on C. I want him to be able to click a button on a form and have the data appended to the table. Can anyone give me any pointers in developing the most effecient VBA code?

Thanks.

Charles
 
Charles,

Place the ollowing code on the OnClick event of a button on a form. Assign values to the variables, as per your particular required configuration.

'-----------------------------------------------------------------------------
'Set up viariables to control source and destination folders, tables, database.
'Note the target database and table structure MUST already exist.
'Set the next four variables as per your requirement.
'-----------------------------------------------------------------------------
SourceDBaseTable = "YourDBaseTable"
SourcePath = "A:\"
DestAccessTable = "YourTargetAccessTable"
DestAccessDatabase = "C:\YourPath\YourTargetAccessDatabase.mdb"

'------------------------------------------------------------------------
'Prevent Access append warnings, and append source records to destination
'database's table
'------------------------------------------------------------------------
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO " & DestAccessTable & " IN '" & DestAccessDatabase & "' " & _
"SELECT * " & _
"FROM " & SourceDBaseTable & _
" IN '' [dBase IV;HDR=NO;IMEX=2;DATABASE=" & SourcePath & "];"
DoCmd.SetWarnings True

Good luck
Cheers,
Steve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top