Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT * FROM IN-problem

Status
Not open for further replies.

Pampers

Technical User
Apr 7, 2004
1,300
AN
Hi everyone,
I'm trying to execute (in vba-code) a query from another database then where the code is running. Can't get it to work. Error message is that it cannot find the object.
Code:
strQuery = "SELECT * FROM qryContainerMovesEDI " & _
"IN \\Svr-file01\data\Shared\AAASeaTrade\Seatrade_be.mdb"

Currentdb.Execute(strQuery)

Pampers [afro]
Keeping it simple can be complicated
 
The CurrentDb.Execute(strQuery) is a bit nonsense here. I want to do a transferspreadsheet, like:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, strQuery, strInputFileName, False

Pampers [afro]
Keeping it simple can be complicated
 
Mmmmh,
Strange, if I use the query to create a recordset, there is no problem.... If I use it in the docmd.transferspreadsheet it causes an error.

Pampers [afro]
Keeping it simple can be complicated
 
and I can use a table to refer to, and I can use the query in query-designer...but not the query in transferspreadsheet...



Pampers [afro]
Keeping it simple can be complicated
 
I'm talking to myself here.

Table doesn;t work either.
If I use the query designer it works
if I use vba it doesn;t work
I'm puzzled, or just dumb

Pampers [afro]
Keeping it simple can be complicated
 
I have also had some duficulties w / " In ... " statements. I have been able to overcome most / all of these to some degree:

Create a SELECT query actually IN the foregin db.

Test this works in the foregin db.

Copy the SQL to your 'Local' db.

Set a string equal to the sql string.

Add the insert int clause as the predesor to the sql string

Add the In Clause.

So far, so good.





MichaelRed


 
try

Code:
strQuery = "SELECT * FROM qryContainerMovesEDI " & _
"IN '\\Svr-file01\data\Shared\AAASeaTrade\Seatrade_be.mdb'"
 
Hi guys, thanks a lot, I'm gonna give both a try... Keep you posted.

Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top