Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to apply an action query to a second database.

Posted on 2014-11-19
7
Medium Priority
?
106 Views
Last Modified: 2015-02-02
I have opened a second database which I can update with code.  (.addnew .update, etc.) but how can I do it with a query?

Thanks in advance.
0
Comment
Question by:CRB1609
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 750 total points
ID: 40454365
Hi,

I suppose you have an ADO connection

then pls try

.Execute

Sub test()

Dim objCommand As ADODB.Command
Set objCommand = New ADODB.Command

With objCommand
.ActiveConnection = ADOConn
.CommandText = "UPDATE Clients " & _
"set ClientName = 'John' " & _
"Where ClientID = 10"
.Execute
End With

End Sub

Open in new window


Regards
0
 

Author Comment

by:CRB1609
ID: 40454455
Thanks, but I should been more clear.  I want to create the query in Query Design and apply the completed query by name.    I was hoping to do something like this:

  Dim dbe As PrivDBEngine, wrk As Workspace, db1 As Database, db2 As Database
   Dim, OutputFilePath As String

   OutputFilePath = "C:\Celebrant Assist V3\CelaRept.accdb"
   Set dbe = New PrivDBEngine
   Set wrk = dbe.Workspaces(0)
   Set db2 = wrk.OpenDatabase(OutputFilePath, False, False)

  '  Run a named querythat updates a table in db2
0
 
LVL 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 750 total points
ID: 40454521
You can continue:

Dim qdy As QueryDef

Set qdy = db2.CreateQueryDef("NameOfQuery")
qdy.SQL = strSQL ' Your action SQL code.
qdy.Execute

If you like, you can create a temp query this way:

Set qdy = db2.CreateQueryDef("")

/gustav
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:CRB1609
ID: 40463247
It looks like I can't do what I want to do but points for the effort.
0
 

Author Comment

by:CRB1609
ID: 40463265
I give up.  I wanted to award the points to the nexperts but now it seems I can't.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40463270
?

> I have opened a second database which I can update with code.  ..but how can I do it with a query?

I showed you exactly that.

/gustav
0
 

Author Closing Comment

by:CRB1609
ID: 40585617
Thanks for trying.  Sorry I didn't close the question, earlier.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question