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 March 15th, 2005, 03:06 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to make insert statments for current db

I want crerate a vba routine using GenerateInserts() to write insert statmeents for current population of database and it save it into a text file so i can use that to re build the database in sql sever for example.

Example: current database called .Teniss Database and it has 7 tables and each tables has 4 columns and each table has 10 records on it. I want to all the insert statment for all these records be saved in a text file!

I be happy if some one help me here. Thanks

 
Old March 18th, 2005, 12:55 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You mean a .sql file.

Just write the file. Do you know SQL Script?


mmcdonal
 
Old March 18th, 2005, 01:02 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well i want an applecation in access that do that for me and reads all database tables and records and make insert statment for them and save it in a file!

 
Old March 18th, 2005, 01:06 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Whoa! That is a tall order.

You would need to get your system data, and then parse it, and then put in the syntax and writelines to your .sql file.

Once you do this, sell it and make a fortune and retire.

The other option is to pull your Access database into Microsoft Visio PROFESSIONAL database designer, and then export it to SQL. It automates this whole process. It has to be Professional though, since Standard doesn't have the Database designer.

HTH

mmcdonal
 
Old March 18th, 2005, 02:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

In Microsoft Visio 2003 Professional, open a Database design, then Click on Database>Reverse Engineer...

This takes you to some dialog boxes to connect to your database (Set an ODBC for it first to make this easier), and pull in what you need.

When you are satified with the design, go to Tools>Export to Database... and follow the wizards.

HTH


mmcdonal
 
Old March 20th, 2005, 06:38 AM
Authorized User
 
Join Date: Mar 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmcdonal is right. It is SQL.

This is VBA right?
A little array work, and send it to the text editor that accepts createobject.

The SQL lines in VBA are of str value and need a little bit practice.

If you engage SQL in VBA please ask for more details or goto
Visal Basic and VBA:Access VBA:Report based on query programatically.


 
Old March 23rd, 2005, 08:30 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mmcdonal
 Whoa! That is a tall order.

You would need to get your system data, and then parse it, and then put in the syntax and writelines to your .sql file.

Once you do this, sell it and make a fortune and retire.

The other option is to pull your Access database into Microsoft Visio PROFESSIONAL database designer, and then export it to SQL. It automates this whole process. It has to be Professional though, since Standard doesn't have the Database designer.

HTH

mmcdonal
well i know visio can do that! But i am trying to build an access form that has buton and once you click on it, it goes trought each table in db and counts the number of records and generates that many insert statment and it display it .

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

You're going to have to “roll your own.”
Iterate through the Tabledefs collection, getting each tabledef.
Create an array of the fieldnames and their types.
Open a recordset on the table
Looping through the recordset, use that array to write out to a file the insert statement with the fieldnames from the array, syntax according to the field types you found, and data from the recordset.

It's a lot of work...
 
Old March 23rd, 2005, 10:47 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Method,

You already asked this question!

See http://p2p.wrox.com/topic.asp?TOPIC_ID=27774

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert current date vsempoux XSLT 10 July 11th, 2008 07:31 AM
Webpage with DB conection make SQL OVERFLOW rtr1900 Classic ASP Databases 3 March 28th, 2008 07:30 AM
how to run a set of SQL statments in AS400 sivuj18 ADO.NET 0 December 20th, 2007 11:39 PM
could smb help to make run the DB on a hoster? fewer ASP.NET 2.0 Basics 3 December 3rd, 2006 06:52 PM
trigger to insert current date on insert kev_79 SQL Server 2000 3 January 23rd, 2006 05:58 PM





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