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

Is it possible to use the command "DoCmd.RunSql" in relation to a different database

Is it possible to use the command "DoCmd.RunSql" in relation to other database than the current database?

ACCESS 2010 code:
Expand|Select|Wrap|Line Numbers
  1. Dim db1 As Database, db2 As Database
  2. Set db1 = CurrentDb
  3. Debug.Print db1.Name            'returns c:\Users\Kombi\Documents\Database1.accdb
  4.  
  5. Set db2 = OpenDatabase("c:\Users\Kombi\Documents\Database2.accdb")
  6.  
  7. 'table1 is in c:\Users\Kombi\Documents\Database1.accdb
  8. DoCmd.RunSQL "drop table table1"            'it works OK
  9.  
  10. 'table2 is in c:\Users\Kombi\Documents\Database2.accdb
  11. 'I would like to use something like this:
  12. DoCmd.RunSQL "drop table table2"
Jun 30 '15 #1
2 1940
TheSmileyCoder
2,322 Expert Mod 2GB
Best I recall, the syntax is:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "drop table table2 in 'c:\Users\Kombi\Documents\Database2.accdb'"
Test at your own peril :)
Jul 1 '15 #2
zmbd
5,501 Expert Mod 4TB
TheSmileyCoder: matches the code in one of the databases I've inherited and the code that I found online.
Jul 11 '15 #3

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

Similar topics

20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
3
by: WindAndWaves | last post by:
Hi there, Can anyone tell me how I can run code/macro in a different database??? Below are the two situations where this may be applicable. 1. run a macro/code in another database that sends a...
2
by: Henriksen, Jonas F | last post by:
Hi, is it possible to write a trigger, using pl/pgSQL, that updates tables in a different database than the one the trigger is called from? If it is, what is the syntax for calling the other...
2
by: Coquette | last post by:
Hi all. I'm new here. I wanted to ask your opinion about *joining two tables* from *two different database* together. Is *that* possible? My project requires me to join identical tables from...
2
by: scott.alfon | last post by:
Hello, i need your help. I want to implement a php-script where I can access to different database types as PostSQL, MySQL etc. Is that possible? Furthermore I want to include an access...
1
by: tarabztk | last post by:
MSACCESS 2003 : How to use command buttons to display different subforms I have an application that display information about Pipelines and these pipelines have many other equipments attached to...
3
by: mayo | last post by:
just want to ask, is it possible to create views in which i will join tables from two different database? how?
2
by: ezly80 | last post by:
hai... i have problems to connect the jboss server with two different database which is Oracle and Mysql. this two db have same db name example Student. if one of the db corrupt the server can...
1
by: Frank Marsella | last post by:
From a command button on a form, how can I open a second form which resides in a different database?
2
by: Sanjay Dey | last post by:
Hi !!! I want to write search query for multiple database. I have 3 different database and each database contains nearly 60 tables. Now i want to create search function for user which will...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.