Public Function RunSQL(StatType As Integer, MainStat As String, FroStat As String, WheStat As String, OrdStat As String, WasERROR As Boolean, ERROR As String, Optional CTable As String) As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim RCHeaders() As String 'The Results Table column headers
Dim SRCHeaders As String 'Holds all the column headers as a string
Dim RTable() As String 'The Results Table
Dim SRTable As String 'Holds the whole table as a string
Dim RTColumns As Integer 'Total number of columns
Dim RTRows As Integer 'Total number of rows
Dim TCHeaders() As String 'The Real Tables column headers
Dim TTable() As String 'The Real Table
Dim TTColumns As Integer 'Total Number of columns
Dim TTRows As Integer 'Total number of rows
Dim LIDoing As Integer 'Used for working out which item is being used in an array
Dim MainLst() As String 'Lists all of the Main statments (ie. parts of the Select, Delete statments0
Dim MainCount As Integer 'Keeps a count of all the main statments
Dim MaiUpTo As Integer 'Used for working out where the next main statment is to go
Dim FroTab() As String 'List of all the from statments (only two possible ones)
Dim FroCount As Integer 'Keeps a count of all the from statments
Dim WheLst() As String 'List of all the where statment
Dim WheCount As Integer 'Keeps a count of all the where statments
Dim WheUpTo As Integer 'Holds where where upto count
Dim CInfo As String 'Column Info all
Dim TInfo As String 'All table items
Dim CTSplit() As String 'Split of the Table Items & Column Items
Dim SCInfo() As String 'Split of the column headers
Dim CInfoI As Integer 'Total column header strings
Dim STInfo() As String 'Split of the Table Info
Dim TInfoI As Integer 'Total Table Info strings
Dim CDoing As Integer
Dim RCount As Integer 'Total nubmer of rows returned
Dim RStart As Integer 'The row to start at
Dim RStop As Integer 'The row to stop at
'Used for spliting up the where statment
Dim RBO As Boolean 'Used to check if a round bracket is open i. ( )
Dim SBo As Boolean 'Used to check if a square bracket is open ie. [ ]
Dim QOp As Boolean 'Used to check if a quote is open
Dim SPos As Integer 'Used to hold where the item spliter is ie ]![ in a Where statment
Dim LineIsOk As Boolean 'Used to telling if a row in a table is ok when all where comparisions are done
'Used for spliting up the where statment
Dim ComPos As Integer
RCount = 0
RStart = 0
RStop = 0
MainCount = CountSubStrings(MainStat, ",") + 1
If MainCount < 1 Then
MainCount = 1
End If
If StatType = 2 Then
ReDim MainLst(MainCount, 2)
Else
ReDim MainLst(MainCount, 1)
End If
If RemoveBrackets(MainStat) = "*" Then
MainStat = RemoveBrackets(MainStat)
End If
If ContainsText(",", MainStat) = True And Trim(MainStat) <> "*" Then
'MainLst = Split(MainStat, ",")
QOp = False
SBo = False
RBO = False
ComPos = 1
MaiUpTo = 0
For i = 1 To Len(MainStat)
Select Case Mid(MainStat, i, 1)
Case Chr(34)
If QOp = True Then
QOp = False
Else
QOp = True
End If
Case "["
If QOp = False Then
SBo = True
End If
Case "]"
If QOp = False Then
SBo = False
End If
Case "("
If QOp = False Then
RBO = True
End If
Case ")"
If QOp = False Then
RBO = False
End If
Case ","
If QOp = False And SBo = False And RBO = False Then