nepotist
09-28-2010, 12:05 PM
Hello I am programming in ArcGIS (using VBA) and using Access as a database.
I have a function that is called to generate a SQL string and this call is made by few other function. It works fine when all other functions call it except for one, which pops an error
Error Number 3075; Description Extra ) in query expression
'((((tblConcurrencySegments.SegmentID)=)))'.
Here is the function that builds the SQl statement
Public Function BuildSQLInfo() As String
Dim sSQLInfo As String
Dim sSegListInfo As String
Dim j As Integer
sSegListInfo = "(tblConcurrencySegments.SegmentID)=" & frmInfoList.ListBox.List(0)
j = 1
Do While j < frmList.ListBox.ListCount
sSegListInfo = sSegListInfo & " OR (tblConcurrencySegments.SegmentID) = " & frmInfoList.ListBox.List(j)
j = j + 1
Loop
MsgBox sSegListInfo
sSQLInfo = "SELECT tblConcurrencySegments.SegmentID, tblConcurrencySegments.RoadName, tblConcurrencySegments.From, tblConcurrencySegments.To, tblProjectList.ConcurrencyID, tblProjectList.ProjectName, tblTripDiary.LinkTrips " _
& "FROM (tblConcurrencySegments INNER JOIN tblTripDiary ON tblConcurrencySegments.SegmentID = tblTripDiary.LinkNumber) INNER JOIN tblProjectList ON tblTripDiary.ConcurrencyID = tblProjectList.ConcurrencyID " _
& "WHERE (((" & sSegListInfo & ")));"
'**********************************************
BuildSQLInfo = sSQLInfo
Debug.Print BuildSQLInfo
MsgBox BuildSQLInfo
End Function
the out put for this function is as follows
SELECT tblConcurrencySegments.SegmentID, tblConcurrencySegments.RoadName, tblConcurrencySegments.From, tblConcurrencySegments.To, tblProjectList.ConcurrencyID, tblProjectList.ProjectName, tblTripDiary.LinkTrips FROM (tblConcurrencySegments INNER JOIN tblTripDiary ON tblConcurrencySegments.SegmentID = tblTripDiary.LinkNumber) INNER JOIN tblProjectList ON tblTripDiary.ConcurrencyID = tblProjectList.ConcurrencyID WHERE ((((tblConcurrencySegments.SegmentID)=)));
I am not sure what is causing the error and the soultion it. I have checked the parenthesis and they look good.
Can anyone see something that I am not able to see??
I have a function that is called to generate a SQL string and this call is made by few other function. It works fine when all other functions call it except for one, which pops an error
Error Number 3075; Description Extra ) in query expression
'((((tblConcurrencySegments.SegmentID)=)))'.
Here is the function that builds the SQl statement
Public Function BuildSQLInfo() As String
Dim sSQLInfo As String
Dim sSegListInfo As String
Dim j As Integer
sSegListInfo = "(tblConcurrencySegments.SegmentID)=" & frmInfoList.ListBox.List(0)
j = 1
Do While j < frmList.ListBox.ListCount
sSegListInfo = sSegListInfo & " OR (tblConcurrencySegments.SegmentID) = " & frmInfoList.ListBox.List(j)
j = j + 1
Loop
MsgBox sSegListInfo
sSQLInfo = "SELECT tblConcurrencySegments.SegmentID, tblConcurrencySegments.RoadName, tblConcurrencySegments.From, tblConcurrencySegments.To, tblProjectList.ConcurrencyID, tblProjectList.ProjectName, tblTripDiary.LinkTrips " _
& "FROM (tblConcurrencySegments INNER JOIN tblTripDiary ON tblConcurrencySegments.SegmentID = tblTripDiary.LinkNumber) INNER JOIN tblProjectList ON tblTripDiary.ConcurrencyID = tblProjectList.ConcurrencyID " _
& "WHERE (((" & sSegListInfo & ")));"
'**********************************************
BuildSQLInfo = sSQLInfo
Debug.Print BuildSQLInfo
MsgBox BuildSQLInfo
End Function
the out put for this function is as follows
SELECT tblConcurrencySegments.SegmentID, tblConcurrencySegments.RoadName, tblConcurrencySegments.From, tblConcurrencySegments.To, tblProjectList.ConcurrencyID, tblProjectList.ProjectName, tblTripDiary.LinkTrips FROM (tblConcurrencySegments INNER JOIN tblTripDiary ON tblConcurrencySegments.SegmentID = tblTripDiary.LinkNumber) INNER JOIN tblProjectList ON tblTripDiary.ConcurrencyID = tblProjectList.ConcurrencyID WHERE ((((tblConcurrencySegments.SegmentID)=)));
I am not sure what is causing the error and the soultion it. I have checked the parenthesis and they look good.
Can anyone see something that I am not able to see??