PDA

View Full Version : Visual Basic Programming for Data Upload to ACCESS


Gareth Horton
July 12th, 2002, 02:05 PM
Bob Yarnall wrote:
> Lee Baker wrote:
> > Does anyone know where I can find the Visual Basic manual for automating the upload of files into ACCESS tables?
> Could you be a little more specific?
> Do you want VB scripting code to run from Windows or the VBA code inside MS Access?
>
I’ve noticed that there continues to be a lot hits on this subject so I thought I would answer the original question that was never qualified.

I have an older version of Monarch (4.05) so I don’t have all the latest functions available to me. What I have been able to do is use a combination of VB Script and Access to automate the process.

Use the following script to create an output file.
Set MonarchObj = CreateObject("Monarch32")
openfile = MonarchObj.SetLogFile("c:monarch
eportsVBS.LOG",False)

openfile = MonarchObj.SetProjectFile("c:monarchPublishContractEmployees.prj")
If openfile Then
MonarchObj.ExportTable("c:MonarchExportContract.wks")
end if

Monarchobj.closealldocuments
Monarchobj.Exit
Set Monarchobj = Nothing

The following Access function could be run from a button on your main form.
Public Function ImportWks()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeLotusWK3, "Monarch", "C:MonarchExportContract.wks", True
' File Type AccTable File In Path has fields names
Exit Function
End Function

Using the Lotus file format works the best. For some reason, I could never get Access to recognize the version of Excel that Monarch exports.