+ Reply to Thread
Results 1 to 2 of 2

ADO Connection Error

  1. #1
    Registered User
    Join Date
    12-20-2010
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    15

    ADO Connection Error

    I am having difficulty in trying to establish a connection to an access DB from my VBA code. The code in bold is throwing up the error.

    Set dbrst = New ADODB.Recordset

    dbrst.ActiveConnection = GlobalConn
    dbrst.CursorType = adOpenKeyset
    dbrst.LockType = adLockPessimistic
    dbrst.CursorLocation = adUseClient
    dbrst.Open "Select * from tblResult where 0=1", _
    Options:=adCmdText


    dbrst.AddNew
    dbrst!date_entered = Me.txtdateentered.Value
    dbrst!business_area = Me.cboBusinessArea.Value
    dbrst!staff_name = Me.cboStaffName.Value
    dbrst!test_name = Me.cbotestName.Value
    dbrst!area_manager = Me.cboAreaManager.Value
    dbrst!team_leader = Me.cboTeamLead.Value
    dbrst!control_total = Me.txtTotalSample.Value
    dbrst!control_passed = Me.txtSamplePassed.Value
    dbrst!submitted_racf = Me.txtbox.Value
    dbrst!date_submitted = Me.txtDateSubmitted.Value


    dbrst.Update

    dbrst.Close



    This is calling a module with the following



    Sub SetUpVars()





    On Error GoTo ConnError





    GlobalConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=" _
    & ThisWorkbook.Path _
    & "\myDB.mdb"

    Set GlobalConn = New ADODB.Connection
    GlobalConn.Open GlobalConnStr

    Exit Sub

    ConnError:

    MsgBox ("Cannot find Database - EXITING APPLICATION " + vbCrLf + vbCrLf + GlobalConnStr)
    End

    I am getting a 3709 error, I cannot figure out for the life of me what is wrong, this codew works for another app I built but is crashing on me now, intially I thought it was reference issue but I have selected and deselected them but no luck ,any help would be appreciated, thanks

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: ADO Connection Error

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1