Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.
Sub AddListObject_FromConnection(ByVal UseWorksheet As Worksheet, MyRcd As ADODB.Recordset, strConnName As String, ByVal strCommandTemplate As String, _ ByVal strConnection As String) Dim UseConnection As WorkbookConnection Dim UseQueryTable As Excel.QueryTable Dim UseWorkbook As Workbook = UseWorksheet.Parent On Error GoTo Err UseWorksheet.Cells.Delete() UseQueryTable = UseWorksheet.ListObjects.Add(0, strConnection, True, XlYesNoGuess.xlYes, UseWorksheet.Range("A1")).QueryTable With UseQueryTable .CommandType = XlCmdType.xlCmdSql .CommandText = MyUniversalClass.ReplaceFields_inRcd(strCommandTemplate, MyRcd) .BackgroundQuery = True .Refresh(BackgroundQuery:=False) End With UseConnection = UseWorkbook.Connections("Connection") Dim MyConn As WorkbookConnection = FindConnection(UseWorksheet.Parent, strConnName) If (Not MyConn Is Nothing) Then MyConn.Delete() End If With UseConnection .Name = strConnName .OLEDBConnection.SaveAsODC("\\dtchyb-casf025\c_wbgint_users\u231237\My Documents\My Data Sources\" & strConnName & ".odc") End With Sub_Exit: Exit Sub Err: Select Case Err.Number Case Else Call MyUniversalClass.PrintError(Err, "AddListObject_FromConnection") Resume Sub_Exit Resume End Select End Sub
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
10 Experts available now in Live!