index > Visual Basic for Applications (VBA) > Can any1 arrange the ADO connection logic for this VBA code-block...

Can any1 arrange the ADO connection logic for this VBA code-block...


Hi all VB developers !

Pls. refer to the following code-block. Can any1 arrange the ADO connection logic for this VBA code-block ?

Set mdxRec = New ADODB.Recordset

If dbh = "" Then

' MsgBox ("Faild")

End If

'dbh.ConnectionTimeout = 360000

Set mdxRec.ActiveConnection = dbh

mdxRec.Source = strMDX

On Error GoTo errHand

mdxRec.Open

dbh.ConnectionTimeout = 360000

' ADDED RECENTLY

''If dbh.Close = False Then

If dbh.State = 1 Then

dbh.Close

End If

On Error GoTo errHand

Set wbBook = ThisWorkbook

Set wkSheet = wbBook.Worksheets(1)

'Read in values from the record set

wkSheet.Cells(9, 1).CopyFromRecordset mdxRec

SubTotalsIns 9, 2, 3, 4, 8, 9, StartDate, EndDate

mdxRec.Close

CloseDBConnection

I have tried to arrange the steps/sequence but faced a lot of errors and

I am primarily a VB.NET guy so I dunno how one really goes about doing it in VBA. Can some1 with VBA background help me sort this out ?!

Thanks in Advance

DotNetDoctor

Sorry, forgot to give the base-info :-

its ADO connection not DAO - however ultimately the above-code-block is Connected Data Access !

Public dbh As New ADODB.Connection

Public dbc As New ADODB.Connection

Public mdbx As New ADOMD.Catalog

DotNetDoctor
reply 2

You can use google to search for other answers

 

More Articles

• Returning the Server Referral By DFS link
• ADO Connection in Ms Access
• screen resolution
• VBA6.4 sdk issues
• Excel Workbook corrupting
• Restricting access to certain tables in Access DB - is this possi...
• printing .doc, .xls, and .pdf files from a list of filenames usin...
• Need help with Split function in VB 6.0
• DLookup help?
• Word 2003 Macros
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Setting the correct row height for merge
• code in visual basic to convert decimal
• Sum of hours using select statement &
• Outlook experienced a serious error: 'mi
• Date Problem
• call addin's userform
• Is an Excel bug that Excel refuse to set
• Access
• Need to Count the replacements made by a
• Automation Error During Execution of Sto
• Program code fro sorting coloumns in a l
• Extract code from .dot
• Access and DWGs
• Help with the application-defined or obj
• Displaying modeless userform while other

Hot Articles

• Outlook 2003 Scripting - Working with en
• Task Scheduler
• Error setting range to hidden in Excel 2
• Personal.xls
• How to use pivot data in function?
• Increase Speed of a Word Macro
• Copy and Paste Values
• Recursive Function
• Defining objects within a cell range
• Excel Range Selection
• paste values from multiple sheets to ano
• Access 2003 - Retrieving computer inform
• Close excel
• VBA Excel - Using The "For each&quo
• show vba application

Recommend Articles

• Can this be done via an array formula?
• Browsing Selection.InlineShapes forces W
• SubForm - ActiveCell
• Bug or Error ?
• A Simple question about vba editor and v
• Personal.xls
• Access 2000 RecordSet Sort problem
• Referencing unregistered DLL
• use vba to drive a quicktime movie?
• DoCmd (1312)
• Compiling a VBA project is increasing it
• VBA Form in MS Word template to populate
• hyperlink --> image needed in Word or
• Access Security Warnings
• dbclick listbox additem