Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error connecting to Access 2002 Db

Status
Not open for further replies.

ChewDoggie

Programmer
Mar 14, 2005
604
US
Hello All!

I have an app that certain users are reporting an error when they attempt to start the application. I searched the archives and found a number of like issues but those problems were solved b/c of some syntax issues. I don't believe my issue can be a syntax issue b/c the app works on 90% of the machines it's installed on.

The Error No. is 3709 and the message is "The connection cannot be used to perform this operation. It is either closed or invalid in this context". It seems that only people running Windows XP are experiencing this.

Why would the connection be OK on some machines and not on others? Is the word "computerid" a reserved word on XP OS?

I just don't know where to start.

Here's my code (it's pretty straight forward):

Code:
Private Sub MDIForm_Activate()
    InDevelopmentMode = True
    MDIForm_Resize
    sql = "select * from computerid"
    Set rsTemp = New ADODB.Recordset
    rsTemp.Open sql, cn
    If rsTemp.EOF Then
        rsTemp.Close
        Toolbar1.Visible = True
        Toolbar1.Enabled = False
        frmRegisterSoftware.Show vbModal
        If Registered Then
            Toolbar1.Enabled = True
        Else
            Toolbar1.Enabled = False
            Unload Me
        End If
    Else
        Registered = True
        Toolbar1.Enabled = True
        rsTemp.Close
    End If
    Exit Sub
End Sub

Private Sub MDIForm_Load()
    Dim sql As String
    
    On Error GoTo ErrorHandler
    Me.Width = Screen.Width
    Me.Height = Screen.Height
    Me.Top = (Screen.Height - Me.Height) / 2
    Me.Left = (Screen.Width - Me.Width) / 2
    Connect
    entId = 0
    Exit Sub
    
ErrorHandler:
    ReferringForm = "frmMain"
    Record_Error Err.Number, Err.Description, "MDIForm_Load"
    Resume Next
End Sub

Public Sub Connect()
    constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\EMS.MDB"
    If Not IsNull(cn) Then
        Set cn = New ADODB.Connection
    End If
    If Not cn.State Then
        cn.Open constr
    End If
    TranErrors = True
    Moto = False
    SubmitError = True
End Sub

Any help would be greatly appreciated.

Thanks!

AMACycle

American Motorcyclist Association
 
I would verify that the app.path does not end with it's own "\". Also check that the Provider and ADODB exists on the machines that are failing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top