Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 22081

Runtime 48 Error loading dll error on CopyTableDef

$
0
0
I am getting a runtime 48 Error loading dll message and failure when this code runs on a windows 7 pro 64 bit machine. It runs on similar machines in other offices. What can I look for to debug this? As you can see I am writing out a log file as I progress through the code. I belive this line For Each tbl In Glob.dbAppDB.TableDefs is where it is throwing the error. Any help is appreciated.
Code:

Private Sub CopyTable(from_name As String, to_name As String)

Dim dbSource As Database
Dim CmdStatement As String
Dim nCtr As Integer
Dim tbl As New TableDef
Dim fld As Field
Dim ind As Index
Dim ds1 As Recordset
Dim ds2 As Recordset
'Dim ds1 As Dynaset
'Dim ds2 As Dynaset
Dim RecSetTable As Recordset
Dim ErrLoc As String
Dim blnTableExists As Boolean

On Error GoTo ErrorRoutine
ErrorCode = 0
''check to see if the table exists, if it does then delete records and move back to VisualScrap
ErrLoc = "CHECKEXIST"
Call WriteErrLog("protocol_CreateTables", "CopyTable", "CreateTbl", "Check if Exist")
blnTableExists = False
For Each tbl In Glob.dbAppDB.TableDefs
    If UCase$(tbl.Name) = UCase(to_name) Then
        blnTableExists = True
        Call WriteErrLog("protocol_CreateTables", "CopyTable", "CreateTbl", "Check if Exist=True")
        Exit For
    End If
Next

'CmdStatement = "SELECT * FROM " & to_name
'Set RecSetTable = Glob.dbAppDB.OpenRecordset(CmdStatement, dbOpenDynaset)
'If ErrorCode = 0 Then
If blnTableExists = True Then
'    RecSetTable.MoveLast
'    If RecSetTable.RecordCount > 0 Then
        ErrLoc = "DELETE PRIOR RECORDS"
        Call WriteErrLog("protocol_CreateTables", "CopyTable", "CreateTbl", "Delete Prior Records")
        If Glob.DataType = 1 Then
            CmdStatement = "DELETE * FROM " & to_name
        Else
            CmdStatement = "DELETE FROM " & to_name
        End If
        Glob.dbAppDB.Execute (CmdStatement)
'    End If
Else
    ErrLoc = "CREATE TABLE"
    Call WriteErrLog("protocol_CreateTables", "CopyTable", "CreateTbl", "CreateTable with TableDefs-" & to_name)
    tbl.Name = to_name
    ErrLoc = "CREATE TABLE-1"
    For nCtr = 0 To Glob.dbAppDB.TableDefs(from_name).Fields.Count - 1
        Set fld = New Field
        ErrLoc = "CREATE TABLE-2    "
        fld.Name = Glob.dbAppDB.TableDefs(from_name).Fields(nCtr).Name
        fld.Type = Glob.dbAppDB.TableDefs(from_name).Fields(nCtr).Type
        fld.Size = Glob.dbAppDB.TableDefs(from_name).Fields(nCtr).Size
        If Glob.dbAppDB.TableDefs(from_name).Fields(nCtr).AllowZeroLength = True Then
            fld.AllowZeroLength = True
        End If
       
        fld.Attributes = Glob.dbAppDB.TableDefs(from_name).Fields(nCtr).Attributes
        ErrLoc = "CREATE TABLE-3"
        tbl.Fields.Append fld
    Next
    ErrLoc = "CREATE TABLE-4"
    For nCtr = 0 To Glob.dbAppDB.TableDefs(from_name).Indexes.Count - 1
        Set ind = New Index
        ErrLoc = "CREATE TABLE-5"
        ind.Name = Glob.dbAppDB.TableDefs(from_name).Indexes(nCtr).Name
        ind.Fields = Glob.dbAppDB.TableDefs(from_name).Indexes(nCtr).Fields
        ind.Unique = Glob.dbAppDB.TableDefs(from_name).Indexes(nCtr).Unique
        ind.Primary = Glob.dbAppDB.TableDefs(from_name).Indexes(nCtr).Primary
        tbl.Indexes.Append ind
    Next
    ErrLoc = "CREATE TABLE-6"
    Glob.dbAppDB.TableDefs.Append tbl
End If
Set RecSetTable = Nothing
ErrLoc = "CREATE TABLE-7"
CmdStatement = "INSERT INTO " + to_name + " SELECT * FROM [" + from_name + "];"
Call WriteErrLog("protocol_CreateTables", "CopyTable", "CreateTbl", "Insert" & CmdStatement)
Glob.dbAppDB.Execute (CmdStatement)
ErrLoc = "CREATE TABLE-8"
strTableCreated = "SUCCESS"

Exit Sub
ErrorRoutine:
'debug.print err.Number
ErrorCode = err.Number
ErrorDesc = err.Description
Call WriteErrLog("protocol_CreateTables", "CopyTable", "CreateTbl", "Error=" & ErrorCode & ErrorDesc)
If ErrorCode = 3078 And ErrLoc = "CHECKEXIST" Then
    Resume Next
End If

strTableCreated = "ERROR:" + ErrorCode + " " + ErrorDesc

Call WriteErrLog("protocolCreateTables", "CopyTable", "CopyTableErr", ErrorCode & " " & ErrorDesc)

End Sub


Viewing all articles
Browse latest Browse all 22081

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>