Creating a new Access database file at runtime.


Ho can I create a new Access database file for Elipse E3 at runtime?


The Database is an Elipse E3 object used for storing the project’s information regarding Historics, Formulas, and Alarms. It can support the following formats: MDB (Microsoft Access), Oracle, and Microsoft SQL Server.

Microsoft Access is a database management system provided by Microsoft. It comes with the Microsoft Office package, and can use any information that has been stored in any data receptacle in the ODBC. If you’re still not sure which database model is the right one for your project, you can check out our article KB-31974: Databases: comparing models to help you make an informed decision.

In order to create a new Access database file from scratch at runtime, you must first follow a few guidelines. First of all, you will need to deactivate all database objects, such as: databases, Historics, and Storage. Then, you must edit the database file; only after you’ve made these changes that can you you reactivate these objects.

An important tip is: If you’re working in a query screen when the file is edited, you will need to remember to update the screen first.
The new file then can be created at runtime. To do so, you can follow the code we present below as an example. This code will deactivate the database’s objects, create a new file based on current data, and then reactivate the DB objects.
Set objHist = Application.GetObject("Hist1")​ Set objDB = Application.GetObject("BancoDados1")

​'Deactivate database objects
'Create a new file based on current data 
Call objDB.SetDBParameters("C:\CaminhoPastas\Dados_"&Day(Now)&"_"&Month(Now)&"_"&Year(Now)&".mdb", "", "", "")​
'Reactivate all database objects 


Related articles:


Este artigo foi útil? Was this post helpful?

Leave a Reply

Your email address will not be published.Required fields are marked *