Topics Search

Import Objects with VBA

Import Objects with VBA
Views: 671
Normally, Tables, Queries or other objects from another database can be imported manually by selecting Import from Get External Data option from File menu. But this can be achieved through VB Code too and this question, HOW TO? is raised in Microsoft Access Users Forums and I thought it is useful to those who look for this solution. Hence, I present the Code here for importing Tables, Queries and Forms separately. The next method imports all Tables from a Source database into the active database except the Microsoft Access System Tables .
Sponsored Links:

More topics

 

Run saved import spec in VBA

Preview
Thought this would be easy, but getting error message

Want to run an import spec that imports and appends data from Excel to my Access table. I ran the import process, saved the import spec, naming it "Import-PGI_Data" then, in my VBA for my button:

DoCmd.RunSavedImportExport "Import-PGI_Data"

I keep getting "argument not optional" error.
 

Importing an Excel file into Access via VBA

Preview
I have found a ton of information on how to import an Access table into Excel, but I have come up short when I have been looking for a way to import an Excel file into Access via VBA.

Currently, I have 3 tables that I update monthly manually by means of the Import Wizard, but I am looking to automate the process as much as possible.

At the least, I would like to hit a button in a form that imports a particular Excel file (the name doesn't change from month to month) and at least brings me into the import wizard.

I am just starting out in VBA,
 

Import from Excel using Import Spec

Preview
Is it possible to import a spreadsheet into Access using an import specification? I've created import specifications to successfully import spreadsheets into Access and I would like to automate those imports using VBA. But, I cannot find the 'DoCmd.TransferSpreadsheet' syntax that'll work. I do not want to convert the spreadsheets to .txt or .csv
 

Change Import/Export directory via VBA

Preview
I would like to change the path of a stored import (Excel) via VBA rather than displaying the Manage Data Tasks window to my end-users. I'd like to display a popup allowing them to search for the correct folder, and then I would insert the selected string.

So far I found Application.CurrentProject.ImportExportSpecificati ons.Item but that is read-only and asking for the name of my stored import
 

Stop users importing objects into another database

Preview
I have a split database created entirely in Access. The BE holds all the tables and is password protected, and the FE holds the queries, forms, reports, macros etc. On one of the forms, there is an event procedure on the On Click property of a label which enables/disables the bypass key.

How can I stop a user from simply creating a new database and importing the objects from mine? Although they can't import the tables themselves, they can import the links and see all the data contained in them, and they can import the forms etc.
 

Stop users importing objects into another database

Preview
I have a split database created entirely in Access. The BE holds all the tables and is password protected, and the FE holds the queries, forms, reports, macros etc. On one of the forms,there is an event procedure on the On Click property of a label which enables/disables the bypass key.

How can I stop a user from simply creating a new database and importing the objects from mine? Although they can't import the tables themselves, they can import the links and see all thedata contained in them, and they can import the forms etc.
 

export secured database

Preview
I have a secured database which is giving me some problems at the moment,it might be corrupted or on the verge of corruption.

When I import the objects into a new db the problems get solved except I do not have the ULS of the old database.

Can I import the database objects with current security settings?
 

Using Left([FieldName],3) to look at the name of a file

Preview
Im looking to import a bunch of files to a table all at once using vba.

I want vba to be able to look at the first 3 letters of the file name to identify it. Then take the next 3 and import all the data to a table.

i.e. file name

999APT130410.txt

I want it to look at [999] which is a code linked to a table
import all the data to a table and add [APT] to the table as an identifyer
 

Importing Data into Microsoft Access using VBA

Preview
You might be wondering why you would want to use VBA code to import data while you have so many other options available when doing it the visual way. Well, there are two main reasons:
Importing data through VBA code enables you to work with a variety of formats that is not available when you do it using the visual interface such as delimited text in a text file or data in a word table.
On a more practical level, if you need to make the same import every time, then simply creating a function to do the job for you will make the process faster and easier as opposed to going through the import wizard every time.
 

Import in Access (2003)

Preview
I want to import a txt.file in Access. If I do it manually, everything is OK. But if I want to do it by VBA : DoCmd.TransferText acImportDelim, "ImportSpecificationBasicFile", "BasicFile", GetImportFile(), True
where BasicFile the name is of the file where to import
GetImportFile() the name is of the file to import
then I receive at some places in the table strange characters :for exemple : Pav d'Ath / Rue Flix Bovie / Rosires

It seems that there is a problem with the special french characters : ,
Could it be a prbl with the codepage? and so how can I resolve it and include in this VBA sentence