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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error # 13 after upgrade from MS Access 2000 to 2003

Status
Not open for further replies.

JoPaBC

Technical User
Sep 26, 2017
85
CA
Hello,

I had installed multiple versions of MS Access (2000 and 2003) on my computer. After uninstalling 2000 version I am getting 'Error # 13' when trying to open any MS Access report from my VB6 program.

ERROR_13_pr7pdf.png


Here is the code (show report):

Code:
Private Sub Command19_Click()
    Dim rst As ADODB.Recordset
    Dim PPID As Integer
    Dim acapp As Access.Application
    Dim Msg As String

    On Error GoTo OnError

    Dim ITEMPLATES As String

    If Combo1.Text = "Select pay period" Then
        MsgBox "Select pay period!"
        Exit Sub
    End If

    'ITEMPLATES = "G:\SALES\PLPRL.mdb"

    Set acapp = GetObject(Text3.Text, "access.application")
    acapp.Visible = True
    acapp.DoCmd.Maximize
    acapp.DoCmd.OpenReport "Report11", acViewPreview, , "PAYPER='" & Combo1.Text & "'"

    Exit Sub

OnError:
    Msg = "Error # " & str(Err.Number) & " was generated by " _
        & Err.Source & Chr(13) & "Error Line: " & Erl & Chr(13) & Err.Description
    MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
End Sub


Connect to the database
Code:
Private Sub Combo2_CLICK()

    Dim rst As ADODB.Recordset

    If Combo2.Text = "PEREGRINE" Then
        Text3.Text = DataLocPRL
        Text3.Refresh
        Text6.Text = ExTimePRL
        Text6.Refresh
        Text2.Text = ExDeductPRL
        Text2.Refresh
    Else
        If Combo2.Text = "FOREX" Then
            Text3.Text = DataLocFRX
            Text3.Refresh
            Text6.Text = ExTimeFRX
            Text6.Refresh
            Text2.Text = ExDeductFRX
            Text2.Refresh
        Else
            Text3.Text = DataLocHFP
            Text3.Refresh
            Text6.Text = ExTimeHFP
            Text6.Refresh
            Text2.Text = ExDeductHFP
            Text2.Refresh
        End If
    End If

    Set objAccessConnection = New ADODB.Connection
    objAccessConnection.CursorLocation = adUseClient

    objAccessConnection.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
                             "Data Source=" & Text3.Text

    If objAccessConnection.State <> adStateOpen Then
        MsgBox "Connection not possible.", 64, "Connection status."
    End If

    sSQL = "Select [PAYPER], [STD] From PAYPER Order by PPID"
    Set rsAccess = New ADODB.Recordset
    rsAccess.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic

    Combo1.AddItem "Select Pay Period"

    While Not rsAccess.EOF
        Combo1.AddItem rsAccess("PAYPER")
        If Right(Year(Now()), 2) <> Right(Year(rsAccess("STD")), 2) Then
            MsgBox "Current year and Pay Period year doesn't match, check Settings-Start Day."
        End If
        rsAccess.MoveNext
    Wend

    sSQL = "Select * From DEDUCT;"
    Set rst = New ADODB.Recordset
    rst.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic

    Text9.Text = rst.Fields(0).Value

    sSQL = "Select * From STATS;"
    Set rsts = New ADODB.Recordset
    rsts.Open sSQL, objAccessConnection, adOpenKeyset, adLockPessimistic

    Set DataGrid5.DataSource = rsts

    With DataGrid5
        .Columns(0).Width = 800
        .Columns(1).Width = 3300
    End With

    DataGrid1.ClearFields

    sSQL = "SELECT [EMPID], [FULL_NAME], [RAB], [TEL] From ENAMES Order by [FULL_NAME];"
    Set rse = New ADODB.Recordset
    rse.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic

    Set DataGrid1.DataSource = rse

    With DataGrid1
        .Columns(0).Width = 800
        .Columns(1).Width = 3300
        .Columns(2).Width = 500
        .Columns(3).Width = 500
    End With

    DataGrid2.ClearFields

    sSQL = "SELECT [PAYPER] AS PERIOD, [PDAYS] AS DAYS, [STD] AS START_DAY From PAYPER order by [ppid];"
    Set rsp = New ADODB.Recordset
    rsp.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic

    Set DataGrid2.DataSource = rsp

    With DataGrid2
        .Columns(0).Width = 2000
        .Columns(1).Width = 1000
        .Columns(2).Width = 2000
    End With

    DataGrid3.ClearFields

    sSQL = "SELECT [ID] AS JOB_CODE, [JOB] AS JOB_DESC, [RATE] AS RATE_TYPE From JOBID ORDER BY [ID];"
    Set rsj = New ADODB.Recordset
    rsj.Open sSQL, objAccessConnection, adOpenKeyset, adLockOptimistic

    Set DataGrid3.DataSource = rsj

    With DataGrid3
        .Columns(0).Width = 900
        .Columns(1).Width = 2800
        .Columns(2).Width = 1500
    End With

    Combo2.Enabled = False
    Combo1.Enabled = True
    Command22.Enabled = True
    SSTab1.Enabled = True
    
End Sub

Otherwise, the program (exe file) itself seems working fine (reading Excel, writing into Access, reading Access, export into TXT file, ...)

However, when trying to run the program from Microsoft Visual Basic I am getting another error when trying to connect the database.
run_time_error_ob9nip.png


Any idea, please?
 
Well, I downloaded and installed the MS Access 2000 runtime and the program is working again.
It isn't the ideal solution, but it works (those report worked and still work OK if run directly from Access 2003).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top