|
Question : VB6 Access SQL query code
|
|
I am programming in VB6 using an Access database. I am trying to select from two tables based on two key IDs using the following flowchart.
DPIssueGroupDetail - dpProperty - dpIssues
The two keys exist in DPIssueGroupDetail and I want to pull data from teh other two tables matching both key fields. The code is below.
strSQL = "Select P.PartNo, I.Quantity, P.Desc from dpIssueGroupDetail IGD " strSQL = strSQL & "INNER JOIN dpProperty P ON P.PartNo = IGD.PartNo AND P.SerialNo = IGD.SerialNo " strSQL = strSQL & "INNER JOIN DPIssues I ON I.PartNo = IGD.PartNo AND I.SerialNo = IGD.SerialNo " strSQL = strSQL & "Where IGD.IssueGroupID = " & cboIssueGroups.ItemData(cboIssueGroups.ListIndex)
When I run this I get a syntax error "Missing operator in query expression." Any idea why? What code can I use for this?
|
|
Answer : VB6 Access SQL query code
|
|
Try this change:
strSQL = "Select P.PartNo, I.Quantity, P.Desc from ((dpIssueGroupDetail IGD " strSQL = strSQL & "INNER JOIN dpProperty P ON (P.PartNo = IGD.PartNo) AND (P.SerialNo = IGD.SerialNo)) " strSQL = strSQL & "INNER JOIN DPIssues I ON (I.PartNo = IGD.PartNo) AND (I.SerialNo = IGD.SerialNo )))" strSQL = strSQL & "Where IGD.IssueGroupID = " & cboIssueGroups.ItemData(cboIssueGroups.ListIndex)
AW
|
|
|