473,490 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VBA (Copying Tables)

18 New Member
Hi

I am trying to copy tables from one DB to another. That's fine with the code below, but could someone explain how the code would work without having the C:\My_Documents\All_Weeks.mdb code in which is the same path as the DB I have open.

I have tried Currentdb etc but nothing working.

Thanks in advance

Andy


Expand|Select|Wrap|Line Numbers
  1. Private Sub Test()
  2.  
  3. Dim strDBPath As String, strTableName As String, appAccess As Access.Application, dbsCurrent As Database
  4.  
  5.  
  6. strDBPath = "C:\My_Documents\BS.mdb"
  7. strTableName = "Users"
  8.  
  9. 'Create a New Instance of Access
  10. Set appAccess = CreateObject("Access.Application")
  11. Set dbsCurrent = CurrentDb
  12.  
  13.  
  14. 'Open the External Database in Access Window
  15. appAccess.OpenCurrentDatabase strDBPath
  16.  
  17. 'Copies the Users table from Batley Spen DB and pastes into the current All_Users DB
  18. appAccess.DoCmd.CopyObject "C:\My_Documents\All_Weeks.mdb", "TBL_BS", acTable, "Users"
  19.  
  20. End Sub
Apr 11 '08 #1
2 1345
nspader
78 New Member
It should look something like this:
Expand|Select|Wrap|Line Numbers
  1. strDBPath = curpath & "\Barwon.mdb"
Hope it works for you.

Nick
Apr 11 '08 #2
NeoPa
32,556 Recognized Expert Moderator MVP
You can find the folder of the current database from CurrentDb.Name. This includes the db name too of course, but the folder can easily be extracted.
Apr 11 '08 #3

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

Similar topics

1
8661
by: Jani Tamminen | last post by:
I want to copy data from our production database to the development database. I want to move only the data. I do not need the table structure, constrains or anything else. I think I can use the...
3
3397
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock...
3
1849
by: Tom van Stiphout | last post by:
I have written some code to export all objects to text files, and to import those files back into a new database. Hopefully this will eliminate some forms of corruption. The icing on the cake...
2
1832
by: Nedu N | last post by:
Hi Techies, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data into typed dataset in order to ease the...
4
15402
by: zMisc | last post by:
Is it possible to copy a table from one schema to another schema by just copying the frm file to the directory for the new schema? What is the best way to create a new database with all the...
2
5340
by: aoao | last post by:
I need to make a new database at the beginning of every year but have forgotten how to do this quickly and efficiently. I have a database with about 10 tables, 10 forms related to the 10 tables...
0
1130
by: RS200Phil | last post by:
Hi all, We have this morning used DTS to copy some objects from one database to another. We removed the tick to "Copy all objects" and selected just the 4 tables that we wanted However, we...
2
2374
by: troy_lee | last post by:
What is the best way of copying all the records from a linked table into a replica table that is local on my computer? This is for development work at home where I can not access the main table. Is...
1
6725
by: tshad | last post by:
Running on VS.net 2005, I am trying to copy rows from my datatable to another datatable in the same dataset. The schema would be identical. I need to make the table name "forms" as I am...
0
1273
by: ElishaThompson | last post by:
I recently had a problem requiring me to locate and copy all records pertaining to a particular client from numerous tables in a database on a given server to tables within an identical database on...
0
7108
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
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
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...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.