Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2005, 02:29 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to Insert data into external db

Hi experts. I want to learn how i can insert data in to external db using vba.
For example , i want insert table names in to the external db.
(A command button in a form )I be happy if some one show me how. Thanks

 
Old May 2nd, 2005, 07:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, it all depends on exactly how you want to do it, and what you're comfortable with.
If you're not that comfortable with Access or programming at all, I'd suggest using Linked Tables.
If you want to do something fancy, and you don't mind programming, it depends on a) what version of access you're using, and b) what method (most likely ADO or DAO) you'd prefer.

But using linked tables would be the easiest - then you can just treat the table like it's local.

Steven

I am a loud man with a very large hat. This means I am in charge
 
Old May 3rd, 2005, 07:06 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank u for u reply. Could u show me an example that inserts data to external mdb file using vba 2000.Thanks

 
Old May 3rd, 2005, 01:14 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Method,

What application is the host for the VBA you are using?
I get the impression that you want to moify (for instance) an .MDB through Word, or Excel.

Please explain your situation a little further.
 
Old May 3rd, 2005, 04:21 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thanks to your reply. well i try to make an access 2000 vba application that has button on the form.And once i click on the button it goes and collects some information about the access db structure such as number of tables and data type ... and then writes writes them to another .mdb file that it has has the approperate tables . My difficulty is how i can wirte those information to the external .mdb file. Thanks

 
Old May 4th, 2005, 10:59 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Though most often a database object is used to refer to the database in which the code resides, there nonetheless is functionality to open a different database.

Having done that, you can use that database object to refer to all of the objects in the external database with exactly the same syntax you would use to reference local objects if the database object referred to the local database. You can open recordsets on the tables and queries in the other db, create and delete tables and such.
Code:
    Set db = DBEngine(0).OpenDatabase("C:\Path\DB.mdb", _
                                      BoolExclusive, _
                                      boolReadOnly)
                                      where BoolExclusive and boolReadOnly are variables of your own (not built-in constants) reflecting the way in which you want to open the external database.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Definitions in External Db pjm Access VBA 3 December 20th, 2007 04:24 PM
insert data param into xml from external file alexshiell XSLT 0 January 24th, 2006 01:47 PM
INSERT INTO <--inserting data into db abbylee26 Classic ASP Databases 2 March 11th, 2004 05:33 PM
Use Objects or just insert data directly to DB? pedrobernardo VB.NET 2002/2003 Basics 3 December 10th, 2003 05:07 PM
Intercept data sent to printer & insert into DB tricia412 VS.NET 2002/2003 0 September 8th, 2003 02:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.