Access SQL Query from another DB

后端 未结 2 1173
无人及你
无人及你 2021-01-15 04:40

I want to apply an SQL query to one Access table, from which it is retrieving data from a table in another Access file. I\'ve looked around on this subject and can\'t seem t

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-15 05:18

    Could you not do this as a single step? Incorporate the output of the first SQL as the input to the "set" in the second?

    In other words,bypass the first query and just do the second using this as the "strUpdate" string:

    strUpdate = "UPDATE TableInCurrentDB" & vbCrLf & _
        "SET [Field1InCurrentDB]=" & vbCrLf & _
        "  (SELECT Val(Nz(Avg(Field1InExternalDB),0))" & vbCrLf & _
        "   FROM TableInExternalDB IN 'C:\VB\ExternalDB.accdb'" & vbCrLf & _
        "   WHERE Field2InExternalDB=Year(Date()) )" & vbCrLf & _
        "WHERE [Field2InCurrentDB]='1';"
    

提交回复
热议问题