473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

code to automate full import - reliable?

I looking for way to reliably automate the process of upgrading users to a
new version of an Access MDE application. I've tried this code a few times
and it seems to work (gets custom menubars, too) but was hoping I could get
a sanity check.

Public Function ImportData() As Boolean
On Error Go To Exit_Here
Dim db As DAO.Database
Dim cdb As DAO.Database
Dim tdf As DAO.TableDef
Dim rel As DAO.Relation
Dim nrel As DAO.Relation
Dim strTDef As String
Dim strRName As String
Dim strTName As String
Dim fld As DAO.Field
Dim strFTName As String
Dim varAtt As Variant
Dim strFName As String
Dim strFFName As String
Dim strOldver As String
strOldver = Oldver 'Oldver is a function that gets the name of the old
version
Set cdb = CurrentDb
Set db = DBEngine.Workspaces(0).OpenDatabase(Oldver, True)
For Each tdf In db.TableDefs
strTDef = tdf.Name
If Left(strTDef, 4) <> "MSys" Then
DoCmd.TransferDatabase acImport, "Microsoft Access", strOldver,
acTable, _
strTDef, strTDef, False
End If
Next
cdb.TableDefs.Refresh
For Each rel In db.Relations
With rel
'get properties of relation to copy
strRName = .Name
strTName = .Table
strFTName = .ForeignTable
varAtt = .Attributes
'create relation in current db with same properties
Set nrel = cdb.CreateRelation(strRName, strTName, strFTName,
varAtt)
For Each fld In .Fields
strFName = fld.Name
strFFName = fld.ForeignName
nrel.Fields.Append nrel.CreateField(strFName)
nrel.Fields(strFName).ForeignName = strFFName
Next
cdb.Relations.Append nrel
End With
Next
cdb.Relations.Refresh
ImportData = True
Exit_Here:
db.Close
Set db = Nothing
Set cdb = Nothing
End Function

The idea is that users would get a new MDE file with no tables - when first
launched, a form would appear with this code behind it. The user types in
the previous version number (of the database with all his precious data) and
clicks "Upgrade Now". Hopefully, everything gets imported properly... and
the new version is deployed. Sound reasonable? (I know... split the
database... that's a work in progress)

Thanks in advance.
Nov 13 '05 #1
0 1187

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kate Gibbs | last post by:
I need to write a simple utility in VB.NET that reads an Excel file, gets some data from a sheet, then...it needs to automate internet explorer in a robot manner. I know that Application Centre...
7
by: Newbillian | last post by:
Is there some way of using vba to automate the processe of joining an Access 97 security workgroup? I typed wrkgadm /? at a command prompt and it just opens the gui, so I'm not sure what the...
0
by: Chanus | last post by:
Hi experts, Can anyone tell me how I can automate "Get External Data" command to import a XML file? I'm looking to build a macro in ACCESS. Any help will be greatly appreciated. Thanks again.
3
by: John Marble | last post by:
I have around 400 excel files filled with data that I need to import in ACCESS. The tricky part is that they must be imported one at time, and properly corrected before importing the next one. I...
0
by: Jill Elaine | last post by:
I want to automate the import of 5 encrypted .db (Paradox) tables into a MS Access 2002 database every time the Access database is opened. I think I could use the TransferDatabase method to import...
1
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed...
5
by: NarayanaR | last post by:
Hello, I'm new to Office(!) but not to programming. I have a requirement that I'm struggling to solve: 1. In Access, I import a List from a sharepoint site as a linked table. 2. I delete all...
0
by: ishay44 | last post by:
Hello! I try to build (using Visual 2005 and Excel 2007) the example described in the Microsoft Help and Support "How to automate Excel from MFC and Visual C++ 2005 or Visual C++ .NET to fill or...
0
by: Apostle | last post by:
I use ctypes to play AUDIO using bass.dll found here: Un4seen Developments - 2MIDI / BASS / MID2XM / MO3 / XM-EXE / XMPlay I have gone so far and tried as they advised me at their forum entry...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.