3146 ODBC调用失败-Access 2010 [英] 3146 ODBC Call Failed - Access 2010

查看:513
本文介绍了3146 ODBC调用失败-Access 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请在下面参考代码...

Please reference code below...

Private Sub Save_Click()
  On Error GoTo err_I9_menu
  Dim dba As Database
  Dim dba2 As Database
  Dim rst As Recordset
  Dim rst1 As Recordset
  Dim rst2 As Recordset
  Dim rst3 As Recordset
  Dim SQL As String
  Dim dateandtime As String
  Dim FileSuffix As String
  Dim folder As String
  Dim strpathname As String
  Dim X As Integer

  X = InStrRev(Me!ListContents, "\")

  Call myprocess(True)

  folder = DLookup("[Folder]", "Locaton", "[LOC_ID] = '" & Forms!frmUtility![Site].Value & "'")
  strpathname = "\\Reman\PlantReports\" & folder & "\HR\Paperless\"
  dateandtime = getdatetime()

  If Nz(ListContents, "") <> "" Then
    Set dba = CurrentDb

    FileSuffix = Mid(Me!ListContents, InStrRev(Me!ListContents, "."), 4)

    SQL = "SELECT Extension FROM tbl_Forms WHERE Type = 'I-9'"
    SQL = SQL & " AND Action = 'Submit'"

    Set rst1 = dba.OpenRecordset(SQL, dbOpenDynaset, dbSeeChanges)

    If Not rst1.EOF Then
      newname = Me!DivisionNumber & "-" & Right(Me!SSN, 4) & "-" & LastName & dateandtime & rst1.Fields("Extension") & FileSuffix
    Else
      newname = Me!DivisionNumber & "-" & Right(Me!SSN, 4) & "-" & LastName & dateandtime & FileSuffix
    End If

    Set moveit = CreateObject("Scripting.FileSystemObject")

    copyto = strpathname & newname
    moveit.MoveFile Me.ListContents, copyto

    Set rst = Nothing
    Set dba = Nothing

  End If

  If Nz(ListContentsHQ, "") <> "" Then
    Set dba2 = CurrentDb

    FileSuffix = Mid(Me.ListContentsHQ, InStrRev(Me.ListContentsHQ, "."), 4)

    SQL = "SELECT Extension FROM tbl_Forms WHERE Type = 'HealthQuestionnaire'"
    SQL = SQL & " AND Action = 'Submit'"

    Set rst3 = dba2.OpenRecordset(SQL, dbOpenDynaset, dbSeeChanges)

    If Not rst3.EOF Then
      newname = Me!DivisionNumber & "-" & Right(Me!SSN, 4) & "-" & LastName & dateandtime & rst3.Fields("Extension") & FileSuffix
    Else
      newname = Me!DivisionNumber & "-" & Right(Me!SSN, 4) & "-" & LastName & dateandtime & FileSuffix
    End If

    Set moveit = CreateObject("Scripting.FileSystemObject")

    copyto = strpathname & newname
    moveit.MoveFile Me.ListContentsHQ, copyto

    Set rst2 = Nothing
    Set dba2 = Nothing

  End If

  Set dba = CurrentDb

  Set rst = dba.OpenRecordset("dbo_tbl_EmploymentLog", dbOpenDynaset, dbSeeChanges)

  rst.AddNew
  rst.Fields("TransactionDate") = Date
  rst.Fields("EmployeeName") = Me.LastName
  rst.Fields("EmployeeSSN") = Me.SSN
  rst.Fields("EmployeeDOB") = Me.EmployeeDOB
  rst.Fields("I9Pathname") = strpathname
  rst.Fields("I9FileSent") = newname
  rst.Fields("Site") = DLookup("Folder", "Locaton", "Loc_ID='" & Forms!frmUtility!Site & "'")
  rst.Fields("UserID") = Forms!frmUtility!user_id
  rst.Fields("HqPathname") = strpathname
  rst.Fields("HqFileSent") = newname2
  rst.Update

  Set dba = Nothing
  Set rst = Nothing

exit_I9_menu:
  Call myprocess(False)
  DivisionNumber = ""
  LastName = ""
  SSN = ""
  ListContents = ""
  ListContentsHQ = ""
  Exit Sub

err_I9_menu:
  Call myprocess(False)
  MsgBox Err.Number & " " & Err.Description
  'MsgBox "The program has encountered an error and the data was NOT saved."
  Exit Sub

End Sub

我一直收到ODBC调用错误.权限都是正确的,并且在有单独的I9和Hq日志表的地方,上一段代码可以正常工作.当有人提交一组包含特定信息的文件时,将调用该例程.

I keep getting an ODBC call error. The permissions are all correct and the previous piece of code worked where there were separate tables for the I9 and Hq logs. The routine is called when someone submits a set of files with specific information.

推荐答案

我通过在SQL中重新创建表而不是在Access中将其放大来解决了这个问题.

I solved this by recreating the table in SQL instead of up-sizing it out of Access.

这篇关于3146 ODBC调用失败-Access 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆