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

Exexuting VBA code from Delphi

Status
Not open for further replies.

cpmasesa

Programmer
Oct 24, 2002
78
AE
Hello,

I need to export data from an access query into a comma delimited text file. I then need to import that file into an access database on a different computer. (This is done every day, data from 15 different computers is imported into one computer)

We currently do it in Access by running VB code that exports the data and another one to import the data onto the 'central' computer

The VB code, in access, to export the data is of the form:
DoCmd.TransferText acExportDelim 'ImpExportFormat', 'SourceQuery', 'Exported filename - full path'

The VB code, in access, to import the files is of the form:
DoCmd.TransferText acImportDelim 'ImpExportFormat', 'DestinationTable', 'Imported file name - full path'

I have just developed a front end for the database using delphi and would like to achieve the export/import from a button click on the UI.

I use ADO to access the database

There is no component for a macro (like you have for a query or table), and TADOCommand expects an SQL command.

Can somebody pls show me how to achieve the above through delphi??

TIA

cpmasesa
 
I'm not sure if this is the correct answer. But try looking at the ShellExecute command!
 
I know you can use the SaveToFile method of a query (which will return your recordset) to export data to a file but formats are ADTG and XML. Maybe you can work around that problem. The TStringList's SaveToFile method can be used too, but the only way you could do that is passing your recordset to a TStringList object first, which may take a little time.

I hope I am not confusing you.
 
Have you looked into the Servers page in Delphi? It has some Access interface (including Macros and Modules). I usually use OLE objects, but I'm trying out the server components.

HTH

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top