473,387 Members | 1,687 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,387 software developers and data experts.

Copying queries from one Access DB to another eliminating duplicates

Hi,

I am new to VB application development with Access. I have a task of copying queries from one DB to another, without duplicationg the ones that are already existing in the destination DB (the names of the queries are taken to be the duplicating factor).


i tried using the DoCmd object, with the method TransferDatabase. But I'm not able use the DoCmd object itself. I have referenced the app to MS DAO 3.6. Do I need to reference it to something eles or am I doing something inherently wrong.

Any feedback would be appreciated
Sep 9 '07 #1
10 4301
MMcCarthy
14,534 Expert Mod 8TB
DoCmd has a copy object action. The following is taken directly from Access Help. If there is anything you don't understand just let me know.
DoCmd.CopyObject destinationdatabase, newname, ObjectType, sourceobjectname

The CopyObject action has the following arguments.

Destination Database
A valid path and file name for the destination database. Enter the path and file name in the Destination Database box in the Action Arguments section of the Macro window. Leave this argument blank if you want to select the current database.
Note
This argument is only available in the Microsoft Access database environment (.mdb). When using this action in an Access project environment (.adp), the Destination Database argument must be blank.

If you run a macro containing the CopyObject action in a library database and leave this argument blank, Microsoft Access will copy the object into the library database.

New Name
A new name for the object. When copying to a different database, leave this argument blank to keep the same name.

Source Object Type
The object type you want to copy. Click Table, Query, Form, Report, Macro, Module. Data Access Page, Server View, Diagram, Stored Procedure. To copy the object selected in the Database window, leave this argument blank.

Source Object Name
The name of the object to be copied. The Source Object Name box shows all objects in the database of the type selected by the Source Object Type argument. In the Source Object Name box, click the object to copy. If you leave the Source Object Type argument blank, leave this argument blank also. If you run a macro containing the CopyObject action in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.


Remarks

You must enter a value for either one or both of the Destination Database and New Name arguments for this action.

If you leave the Source Object Type and Source Object Name arguments blank, Microsoft Access copies the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action with the In Database Window argument set to Yes.

The CopyObject action is similar to selecting an object in the Database window, clicking Copy on the Edit menu, and then clicking Paste on the Edit menu. The Paste As dialog box appears so you can give the object a new name. The CopyObject action performs all of these steps automatically.

The path and file name of the destination database must exist before the macro runs the CopyObject action. If they don't exist, Microsoft Access displays an error message.
Sep 9 '07 #2
DoCmd has a copy object action. The following is taken directly from Access Help. If there is anything you don't understand just let me know.
DoCmd.CopyObject destinationdatabase, newname, ObjectType, sourceobjectname
Well, my problem is, I'm not able to use DoCmd as an object. Sorry if I sound like a moron. I have a VB Windows application. Have referenced it to Microsoft DAO 3.6. I try to use DoCmd for calling the TransferDatabase method, but I can't as it says 'DoCmd' is not defined. Even the intellisense does not show it up.

Can you please help?
Sep 9 '07 #3
Scott Price
1,384 Expert 1GB
DoCmd is an Access specific command of VBA. That means it won't run in VB6, nor in any other of the many flavors of Visual Basic.

You say you are importing from one Access DB to another, so you should have no troubles using this INSIDE the Access DB you are transferring INTO... OR inside the Access DB you are transferring FROM.

Regards,
Scott
Sep 9 '07 #4
FishVal
2,653 Expert 2GB
Well, my problem is, I'm not able to use DoCmd as an object. Sorry if I sound like a moron. I have a VB Windows application. Have referenced it to Microsoft DAO 3.6. I try to use DoCmd for calling the TransferDatabase method, but I can't as it says 'DoCmd' is not defined. Even the intellisense does not show it up.

Can you please help?
Access.Application class has property DoCmd returning DoCmd object.
Library: Microsoft Access XX.X Object Library.
Did you try this?
Sep 9 '07 #5
Access.Application class has property DoCmd returning DoCmd object.
Library: Microsoft Access XX.X Object Library.
Did you try this?

Well.. I tried referencing MS Access Object Library. But did not try the Access.Application class. Can you give me an example with the usage?


Thanks for the help
Sep 9 '07 #6
DoCmd is an Access specific command of VBA. That means it won't run in VB6, nor in any other of the many flavors of Visual Basic.

You say you are importing from one Access DB to another, so you should have no troubles using this INSIDE the Access DB you are transferring INTO... OR inside the Access DB you are transferring FROM.

Regards,
Scott

As I said, I'm totally new to Access. I'm more of an SQL guy. Anyways, I need to have a standalone app on VB.NET.

Any chance I can do something about it?
Sep 9 '07 #7
FishVal
2,653 Expert 2GB
Well.. I tried referencing MS Access Object Library. But did not try the Access.Application class. Can you give me an example with the usage?


Thanks for the help
Something like this. Hope VBA syntax does not differ much from VB syntax.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim appAccess as Access.Application
  3.  
  4. Set appAccess = CreateObject("Access.Application")
  5.  
  6. With appAccess
  7.     .Visible = True
  8.     .OpenCurrentDatabase "X:\db1.mdb"
  9.     .DoCmd.CopyObject .......................
  10. End With
  11.  
  12. Set appAccess = Nothing
  13.  
  14.  
Sep 9 '07 #8
Something like this. Hope VBA syntax does not differ much from VB syntax.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim appAccess as Access.Application
  3.  
  4. Set appAccess = CreateObject("Access.Application")
  5.  
  6. With appAccess
  7.     .Visible = True
  8.     .OpenCurrentDatabase "X:\db1.mdb"
  9.     .DoCmd.CopyObject .......................
  10. End With
  11.  
  12. Set appAccess = Nothing
  13.  
  14.  
Well, I referenced my app to MS Access Object Library, but I do not get Access.Application!
Sep 11 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
Well, I referenced my app to MS Access Object Library, but I do not get Access.Application!
Did you get the DoCmd ?
Sep 11 '07 #10
Did you get the DoCmd ?

Thank you people. I managed to work it out. I used Access.Application to invoke the DoCmd.


Thanks again
Sep 11 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bob | last post by:
How can I copy query objects from one MS Access database to another using VB.net. Both databases are on the same computer. As I create a report using vb.net, I create and reference queries in a...
7
by: D | last post by:
18k queries against 70k rows query: select cn from geoip where between start and end table: "start_ip","end_ip","start","end","cc","cn"...
1
by: MHenry | last post by:
Hi, I have a table with duplicate records. Some of the duplicates need to be eliminated from the table and some need not. A duplicate record does not need to be eliminated if the one record...
6
by: Marlene | last post by:
Hi All I have the following scenario, where I have found all the duplicates in a table, based on an order number and a part number (item).I might have something like this: Order PODate Rec...
2
by: Bob | last post by:
How do I program vb.net to copy a query or table from one MS Access database to another? I'd like to accomplish what import does when it copies Access objects (primarily queries but some tables)...
6
by: Jeemo | last post by:
I've been tearing my hair out on this one. This effin' database keeps crashing on me while I'm doing query-related operations. System info: Access 2003 SP2 with all the latest updates on an XP...
3
by: italia | last post by:
I have a database with 2 columns and more than million rows. The first column is the id Example of the data (2 columns)- 04731 CRM 04731 CRM 04731 CRM 04731 RVB 04731 RVB
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.