我尝试删除关联表时遇到错误3125。

huangapple go评论67阅读模式
英文:

I get error 3125 when I try to delete a linked table

问题

我正在尝试删除我的前端中的所有关联表,但在第一个表格上失败,出现错误:3125“'attendeesSearch'不是有效名称。请确保它不包含无效字符或标点符号,并且长度不要太长。”

这个表格包含一个多值字段。我提到这一点是因为这可能是一个问题。

我尝试过使用“删除表...”SQL和DoCmd.DeleteObject方法。

我的例程:

英文:

I'm trying to delete all the linked tables in my front end, but it fails on the first table with the error: 3125 "'attendeesSearch' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.".

This table contains a multi-valued field. I include this because it may be an issue.

I've tried using "Drop table..." SQL and DoCmd.DeleteObject method.

My routine:


Sub relinkRequestHelp()
   Const csConnnectPrefix  As String = ";DATABASE="
   Dim bLenConnectPrefix   As Byte
   Dim db As dao.Database
   Dim tbl As dao.TableDef
   Dim s As String
   
   On Error GoTo eh
   bLenConnectPrefix = Len(csConnnectPrefix)
   Set db = CurrentDb()
   For Each tbl In db.TableDefs
      If Left(tbl.Connect, bLenConnectPrefix) = csConnnectPrefix Then
'         s = "DROP TABLE " & tbl.Name & ";"
'         Debug.Print s
'         db.Execute s, dbFailOnError
'         Debug.Print , db.RecordsAffected
         DoCmd.DeleteObject acTable, tbl.Name
      End If
   Next
   
   Exit Sub
   
eh: Debug.Print Err.Number, Err.Description
End Sub

Any suggestions?

答案1

得分: 0

删除集合中的当前对象。这对我来说有效:

对于每个 tbl 在 db.TableDefs 中
    如果左(tbl.Connect, bLenConnectPrefix) = csConnnectPrefix Then
        db.TableDefs.Delete tbl.Name
    结束 如果
下一个
英文:

Delete the current object from the collection. That works for me:

For Each tbl In db.TableDefs
    If Left(tbl.Connect, bLenConnectPrefix) = csConnnectPrefix Then
        db.TableDefs.Delete tbl.Name
    End If
Next

答案2

得分: 0

在这个帖子中,Daniel Pineault建议我从所有关系中移除有问题的表格。

一旦我这样做了,我就能够删除链接的表格。

英文:

In this post, Daniel Pineault suggested I remove the troubled table from all relationships.

Once I did that, I was able to delete the linked table.

huangapple
  • 本文由 发表于 2020年1月7日 02:05:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616860.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定