J
John Ortt
Hi there,
I am trying to understand a section of VB code used to update our database
and the following line is confusing me:
Coop_SQL = "SELECT * FROM COOP_Purchase_Orders_Table WHERE [COL_Link] =""" &
Import_Query![Col_link] & """ ORDER BY [Firm_Date]"
I can't understand why there are 3 quotation marks or even what it is trying
to do exactly.
I understand that it is trying to run an SQL select query on the
Purchase_Orders_Table and that it is ordering by Firm_Date but aside from
that I'm lost (i.e what is the Import_Query bit all about?)
Any help would be greatly appreciated.
Thankyou,
John
P.S. I will enclose the full Function below to give an idea of context
Function Update_Details_With_COOP_Data()
Dim MyDB As Database, Import_Query As Recordset, MyWrk As Workspace
Dim strSQL As String, Coop_SQL As String, COOP_Data As Recordset
Set MyWrk = DBEngine.Workspaces(0)
Set MyDB = CurrentDb
strSQL = "SELECT * FROM Details_Table"
Set Import_Query = MyDB.OpenRecordset(strSQL)
With Import_Query
..MoveFirst
Do Until .EOF
Coop_SQL = "SELECT * FROM COOP_Purchase_Orders_Table WHERE
[COL_Link] =""" & Import_Query![Col_link] & """ ORDER BY [Firm_Date]"
Set COOP_Data = MyDB.OpenRecordset(Coop_SQL)
If COOP_Data.RecordCount > 0 Then
.Edit
![AQUISITION] = COOP_Data![AQUISITION]
If COOP_Data![Firm_Date] <> "" Then ![Firm_Date] =
COOP_Data![Firm_Date]
![PO_Number] = COOP_Data![PO_Number]
![System] = COOP_Data![System]
![MMS_Link] = COOP_Data![MMS_Link]
.Update
End If
.MoveNext
Loop
End With
DoEvents
End Function
I am trying to understand a section of VB code used to update our database
and the following line is confusing me:
Coop_SQL = "SELECT * FROM COOP_Purchase_Orders_Table WHERE [COL_Link] =""" &
Import_Query![Col_link] & """ ORDER BY [Firm_Date]"
I can't understand why there are 3 quotation marks or even what it is trying
to do exactly.
I understand that it is trying to run an SQL select query on the
Purchase_Orders_Table and that it is ordering by Firm_Date but aside from
that I'm lost (i.e what is the Import_Query bit all about?)
Any help would be greatly appreciated.
Thankyou,
John
P.S. I will enclose the full Function below to give an idea of context
Function Update_Details_With_COOP_Data()
Dim MyDB As Database, Import_Query As Recordset, MyWrk As Workspace
Dim strSQL As String, Coop_SQL As String, COOP_Data As Recordset
Set MyWrk = DBEngine.Workspaces(0)
Set MyDB = CurrentDb
strSQL = "SELECT * FROM Details_Table"
Set Import_Query = MyDB.OpenRecordset(strSQL)
With Import_Query
..MoveFirst
Do Until .EOF
Coop_SQL = "SELECT * FROM COOP_Purchase_Orders_Table WHERE
[COL_Link] =""" & Import_Query![Col_link] & """ ORDER BY [Firm_Date]"
Set COOP_Data = MyDB.OpenRecordset(Coop_SQL)
If COOP_Data.RecordCount > 0 Then
.Edit
![AQUISITION] = COOP_Data![AQUISITION]
If COOP_Data![Firm_Date] <> "" Then ![Firm_Date] =
COOP_Data![Firm_Date]
![PO_Number] = COOP_Data![PO_Number]
![System] = COOP_Data![System]
![MMS_Link] = COOP_Data![MMS_Link]
.Update
End If
.MoveNext
Loop
End With
DoEvents
End Function