Function GetData(strSQL)
Dim a(0, 0)
'works with a select query to the DB then re-orders and returns data
Dim rs As New ADODB.Recordset
Dim TT()
GetData = a
rs.Open strSQL, cn
If rs.EOF Then Exit Function
Xdata = rs.GetRows
Xcols = UBound(Xdata)
Xrows = UBound(Xdata, 2)
ReDim TT(Xrows + 1, Xcols)
For rdx = 0 To Xrows
For cdx = 0 To Xcols
TT(rdx + 1, cdx) = Xdata(cdx, rdx)
Next cdx
Next rdx

With rs
For cdx = 0 To .Fields.Count - 1
TT(0, cdx) = .Fields(cdx).Name
Next cdx

End With

GetData = TT
rs.Close
End Function

asdfasdfa Function MSDateToSQL(Adate) As String 'SQL Recognises a string "YYYY-MM_DD" as a date SQ = Chr(39) MSDateToSQL = SQ & Format(Adate, "YYYY-mm-dd") & SQ End Function Q1 = Chr(39) Q2 = Chr(34) strSQL = "SELECT * FROM ClaimTable WHERE ClaimStatus = " & Q1 & "Awaiting Payment" & Q1 & " OR ClaimStatus = " & Q1 & "Awaiting Claim Approval" & Q1 strSQL = "SELECT * FROM Programs WHERE CDF_ID = " & Q1 & ClaimData(rdx, 1) & Q1 SelString = "SELECT * FROM " & ThisTable Xjoin = " WHERE " SelString = SelString & Xjoin & ctrl.Name & " = " & Q2 & Trim(ctrl.Value) & Q2