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

Import tables into Updated database 1

Status
Not open for further replies.

deduct

Programmer
Jul 5, 2002
78
0
0
US
Say I have a database with four tables. This database is used by various people as a standalone application at various locations throughout the state. Next suppose I release an updated version that will work with the existing four tables. I would like to put a command button in my updated application (or use some other method) to import those four tables.

I would need to have the code inquire as to the name of the existing database name, then have it copy the four tables into the updated datebase. Any coding suggestions? Thanks in advance.

Karl
 
See if this will get you what you want.

Code:
Dim fd As FileDialog
Dim fName As String

Set fd = Application.FileDialog(msoFileDialogOpen)
    With fd
        .InitialFileName = "C:\"
        .Filters.Add "MS Access Databases", "*.mdb", 1
        .AllowMultiSelect = False
        If .Show = -1 Then
            fName = fd.SelectedItems(1)
        End If
    End With
    If fName <> "" Then
        DoCmd.TransferDatabase acImport, _
            "Microsoft Access", fName, acTable, _
            "NameOfTableToImport", "NameOfDestinationTable"
    End If

HTH,
Eric
 
It says at "Dim fd As FileDialog" is a "user defined type not defined"

I'm using Access 2002 SP3

Karl
 
Try adding a reference to the Microsoft Office 10.0 object library.

HTH,
Eric

 
I thought aobut that, and it is already checked. I can see it in <globals> in the object browser, but I am lost after that.

Karl
 
Is it checked under Tools\References? That's the only reference that I need to make it work. Also using Access 2002 SP3

If so, I am not sure what the problem is.

Eric
 
I misread your previous post, and it was Access 10.0 I had checked, so when I added Office 10.0 it cured the error.

Thanks - now I will work on the code you gave me. It looks like it will work. I'll let you know.

Karl
 
Your code worked, with the following changes:

1) I had to close the form first.
2) I had to delete the existing table first, as it was just adding another table with a 1 appended to the end.

An additional question:

Will users of this application using filedialog also need to have the Office 10.0 object library 'referenced'?

Karl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top