Is This Right?

D

DS

Do I need to refer to the outside dB twice or is this ok?
Thanks
DS

AllSQL = "INSERT INTO tblTransferDetails (IN '" & REDACT() & "'" & _
"TDQuantity, TDItemID )" & _
"SELECT tblCheckDetailsTMP.CDQuantity, tblCheckDetailsTMP.CDItemID " & _
"FROM tblCheckDetailsTMP IN '" & REDACT() & "'" & _
"WHERE tblCheckDetailsTMP.CDCheckID=Forms!frmFXTransferSelect!TxtOldCheckID
" & _
"AND tblCheckDetailsTMP.CDLineID = Forms!frmFXTransferItem!TxtLeftLine;"
DoCmd.RunSQL (AllSQL)

REDACT() is a function with the path to the outside DB
 
D

Douglas J. Steele

Assuming that REDACT() refers to a Jet database (i.e.: an MDB, MDE, ACCDB or
ACCDE), why not create a reference to the other database and use the Execute
method?

Dim db As DAO.Database
Dim AllSQL As String

Set db = OpenDatabase(REDACT())
AllSQL = "INSERT INTO tblTransferDetails " & _
"(TDQuantity, TDItemID )" & _
"SELECT tblCheckDetailsTMP.CDQuantity, tblCheckDetailsTMP.CDItemID " & _
"FROM tblCheckDetailsTMP " & _
"WHERE tblCheckDetailsTMP.CDCheckID=" & _
Forms!frmFXTransferSelect!TxtOldCheckID & _
" AND tblCheckDetailsTMP.CDLineID = " & _
Forms!frmFXTransferItem!TxtLeftLine;"
db.Execute AllSQL, dbFailOnError

I'm assuming both CDCheckID and CDLineID are numeric fields. If they're
text, you'll need additional quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL Other Database 2
SQL SYNTAX ERROR 8
SELECT INSERT 1
Table Def in Another DB 1
Correct Syntax 2
SQL ORDER BY 1
Select From 1
UNION Error 9

Top