Importing an Access 2000 table into another Access 2000 database with VB Code 
Author Message
 Importing an Access 2000 table into another Access 2000 database with VB Code

I have the VB code to use dir1 listboxes to browse through the network for
all .mdb files.

When the user selects an access 2000 database  in the file1 VB box,
I would like the table within the database (and there's only one table -
we'll call it "temp") selected in the file1 VB box copied to the database
on the local hard drive.  The name of the table ("temp"),  will always be
the same,
even though the names of the databases on the network will differ.

The code so far:

     Dim dbMain As Database
    Dim rsMain As Recordset

    Set dbMain = OpenDatabase(AccessFileName)   'Database on network
selected in file1 VB box containing table "temp"
    On Error Resume Next

    dbMain.Execute "CREATE TABLE " & AccessTableName ;"  'temp

    Set rsMain = dbMain.OpenRecordset(AccessTableName)   'database on local
hard drive

Now I have to copy the table into the database on the local hard drive,
overwriting the existing table called "temp".
Doesn't matter that the local table is overwritten, the data in that table
is done with.

What's next?



Fri, 06 May 2005 06:55:05 GMT  
 Importing an Access 2000 table into another Access 2000 database with VB Code
Try this

Dim dbMain As Database

Set dbMain = OpenDatabase(AccessFileName) 'local file
dbMain.TableDefs.Delete "temp"
dbMain.Execute "SELECT * INTO [temp] IN '" & <Network DB Path> _
                                & "' FROM [temp];"

regards

Ian

** invalid email address, change dk to denmark

Tips & Tricks page http://tips.kingsoft-denmark.com/



Quote:
> I have the VB code to use dir1 listboxes to browse through the network for
> all .mdb files.

> When the user selects an access 2000 database  in the file1 VB box,
> I would like the table within the database (and there's only one table -
> we'll call it "temp") selected in the file1 VB box copied to the database
> on the local hard drive.  The name of the table ("temp"),  will always be
> the same,
> even though the names of the databases on the network will differ.

> The code so far:

>      Dim dbMain As Database
>     Dim rsMain As Recordset

>     Set dbMain = OpenDatabase(AccessFileName)   'Database on network
> selected in file1 VB box containing table "temp"
>     On Error Resume Next

>     dbMain.Execute "CREATE TABLE " & AccessTableName ;"  'temp

>     Set rsMain = dbMain.OpenRecordset(AccessTableName)   'database on
local
> hard drive

> Now I have to copy the table into the database on the local hard drive,
> overwriting the existing table called "temp".
> Doesn't matter that the local table is overwritten, the data in that table
> is done with.

> What's next?



Fri, 06 May 2005 14:50:22 GMT  
 Importing an Access 2000 table into another Access 2000 database with VB Code
When I
Dim dbMain As Database
I get an error message saying
"User-defined type not defined"
I guess there's a reference I haven't loaded, but I don't know which one.


Quote:
> Try this

> Dim dbMain As Database

> Set dbMain = OpenDatabase(AccessFileName) 'local file
> dbMain.TableDefs.Delete "temp"
> dbMain.Execute "SELECT * INTO [temp] IN '" & <Network DB Path> _
>                                 & "' FROM [temp];"

> regards

> Ian

> ** invalid email address, change dk to denmark

> Tips & Tricks page http://tips.kingsoft-denmark.com/



> > I have the VB code to use dir1 listboxes to browse through the network
for
> > all .mdb files.

> > When the user selects an access 2000 database  in the file1 VB box,
> > I would like the table within the database (and there's only one table -
> > we'll call it "temp") selected in the file1 VB box copied to the
database
> > on the local hard drive.  The name of the table ("temp"),  will always
be
> > the same,
> > even though the names of the databases on the network will differ.

> > The code so far:

> >      Dim dbMain As Database
> >     Dim rsMain As Recordset

> >     Set dbMain = OpenDatabase(AccessFileName)   'Database on network
> > selected in file1 VB box containing table "temp"
> >     On Error Resume Next

> >     dbMain.Execute "CREATE TABLE " & AccessTableName ;"  'temp

> >     Set rsMain = dbMain.OpenRecordset(AccessTableName)   'database on
> local
> > hard drive

> > Now I have to copy the table into the database on the local hard drive,
> > overwriting the existing table called "temp".
> > Doesn't matter that the local table is overwritten, the data in that
table
> > is done with.

> > What's next?



Sat, 07 May 2005 09:31:17 GMT  
 Importing an Access 2000 table into another Access 2000 database with VB Code
Anyway, I got it straightened out, but with this code,

Private Sub CmdImport_Click()

Dim dbMain As Database
Set dbMain = OpenDatabase("C:\Datac\DATA.mdb")
dbMain.TableDefs.Delete "tblFloor"
dbMain.Execute "SELECT * INTO tblFoor IN '" & "V:\DATA.mdb" & "' from
tblfloor"

End Sub

I get an "unrecognized database format error 'C:\Datac\Data.mdb'."
Perhaps I didn't follow your instruction exactly.



Quote:
> When I
> Dim dbMain As Database
> I get an error message saying
> "User-defined type not defined"
> I guess there's a reference I haven't loaded, but I don't know which one.



> > Try this

> > Dim dbMain As Database

> > Set dbMain = OpenDatabase(AccessFileName) 'local file
> > dbMain.TableDefs.Delete "temp"
> > dbMain.Execute "SELECT * INTO [temp] IN '" & <Network DB Path> _
> >                                 & "' FROM [temp];"

> > regards

> > Ian

> > ** invalid email address, change dk to denmark

> > Tips & Tricks page http://tips.kingsoft-denmark.com/



> > > I have the VB code to use dir1 listboxes to browse through the network
> for
> > > all .mdb files.

> > > When the user selects an access 2000 database  in the file1 VB box,
> > > I would like the table within the database (and there's only one
table -
> > > we'll call it "temp") selected in the file1 VB box copied to the
> database
> > > on the local hard drive.  The name of the table ("temp"),  will always
> be
> > > the same,
> > > even though the names of the databases on the network will differ.

> > > The code so far:

> > >      Dim dbMain As Database
> > >     Dim rsMain As Recordset

> > >     Set dbMain = OpenDatabase(AccessFileName)   'Database on network
> > > selected in file1 VB box containing table "temp"
> > >     On Error Resume Next

> > >     dbMain.Execute "CREATE TABLE " & AccessTableName ;"  'temp

> > >     Set rsMain = dbMain.OpenRecordset(AccessTableName)   'database on
> > local
> > > hard drive

> > > Now I have to copy the table into the database on the local hard
drive,
> > > overwriting the existing table called "temp".
> > > Doesn't matter that the local table is overwritten, the data in that
> table
> > > is done with.

> > > What's next?



Sat, 07 May 2005 10:04:53 GMT  
 Importing an Access 2000 table into another Access 2000 database with VB Code
Your problem now is you've referenced the wrong DAO library. The remote
database is DAO 3.6 and you've referenced DAO 3.5 or lower

regards

Ian

** invalid email address, change dk to denmark

Tips & Tricks page http://tips.kingsoft-denmark.com/



Quote:
> Anyway, I got it straightened out, but with this code,

> Private Sub CmdImport_Click()

> Dim dbMain As Database
> Set dbMain = OpenDatabase("C:\Datac\DATA.mdb")
> dbMain.TableDefs.Delete "tblFloor"
> dbMain.Execute "SELECT * INTO tblFoor IN '" & "V:\DATA.mdb" & "' from
> tblfloor"

> End Sub

> I get an "unrecognized database format error 'C:\Datac\Data.mdb'."
> Perhaps I didn't follow your instruction exactly.



> > When I
> > Dim dbMain As Database
> > I get an error message saying
> > "User-defined type not defined"
> > I guess there's a reference I haven't loaded, but I don't know which
one.



> > > Try this

> > > Dim dbMain As Database

> > > Set dbMain = OpenDatabase(AccessFileName) 'local file
> > > dbMain.TableDefs.Delete "temp"
> > > dbMain.Execute "SELECT * INTO [temp] IN '" & <Network DB Path> _
> > >                                 & "' FROM [temp];"

> > > regards

> > > Ian

> > > ** invalid email address, change dk to denmark

> > > Tips & Tricks page http://tips.kingsoft-denmark.com/



> > > > I have the VB code to use dir1 listboxes to browse through the
network
> > for
> > > > all .mdb files.

> > > > When the user selects an access 2000 database  in the file1 VB box,
> > > > I would like the table within the database (and there's only one
> table -
> > > > we'll call it "temp") selected in the file1 VB box copied to the
> > database
> > > > on the local hard drive.  The name of the table ("temp"),  will
always
> > be
> > > > the same,
> > > > even though the names of the databases on the network will differ.

> > > > The code so far:

> > > >      Dim dbMain As Database
> > > >     Dim rsMain As Recordset

> > > >     Set dbMain = OpenDatabase(AccessFileName)   'Database on network
> > > > selected in file1 VB box containing table "temp"
> > > >     On Error Resume Next

> > > >     dbMain.Execute "CREATE TABLE " & AccessTableName ;"  'temp

> > > >     Set rsMain = dbMain.OpenRecordset(AccessTableName)   'database
on
> > > local
> > > > hard drive

> > > > Now I have to copy the table into the database on the local hard
> drive,
> > > > overwriting the existing table called "temp".
> > > > Doesn't matter that the local table is overwritten, the data in that
> > table
> > > > is done with.

> > > > What's next?



Sat, 07 May 2005 13:56:46 GMT  
 Importing an Access 2000 table into another Access 2000 database with VB Code
Got the delete code part to work, but not the next line.
I was wondering if I could use an INSERT into SQL statement
rather than the SELECT * INTO.
I'd rather not delete the table, but empty it of all records, and then
append the
table from the networked drive into the table on the local hard drive.
The table names are the same, as is the field structure.

The story so far:

Dim dbMain As Database
Set dbMain = OpenDatabase("C:\Fips.mdb")
'dbMain.Execute "DELETE * FROM fips1;"                               'I'd
rather do this then delete the table

dbMain.Execute "SELECT * INTO fips1 from '" & Me.Dir1 & "\" &
Me.File1.FileName & "' & Fips1;"

dbMain.Close

'now the error message sez
"Runtime error '3125'
The database engine can' t find "c:\Backup\Trips.mdb".   >this is the name
of the test database I'm using, the Me.Dir1 _
& "\" Me.File1.Filename & "' Fips1

The filename is correct, but still I get the error message.


Quote:
> Your problem now is you've referenced the wrong DAO library. The remote
> database is DAO 3.6 and you've referenced DAO 3.5 or lower

> regards



Sun, 08 May 2005 06:28:30 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Creating new Access 97 database by VB code in Access 2000 module

2. Importing Excel Spreadsheet into an Access 2000 Table using VB

3. Distributing VB/Access 2000 Apps to non Access 2000 owners

4. Update a ACCESS 2000 Table with VB code

5. Problem importing a text file to a linked table in Access 2000

6. Import Text file into Access 2000 table

7. Import From Excel 2000 with VBA code into Access 97

8. Access 2000 Exporting/Importing Database Object Groups with Shortcuts

9. importing a freebase 5.0 dos database in Access 2000

10. Linking Access 2000 Table to Outlook 2000 Tasks

11. concacenating a single field from an Access 2000 database while in Word 2000

12. read excel file in access 2000 lire fichier excel dans access 2000

 

 
Powered by phpBB® Forum Software