当使用VBA将Excel工作表导入Access时,如何克服导致运行时3075的单元格中的斜杠



找到了一篇关于这个问题的类似文章,但它使用的是SQL查询,而我使用的是DLookup。我正在将Excel工作表导入Access。我正在获取运行时3075-语法错误(缺少运算符(…'[Component]='没有/想要一辆车'。该特定组件已经存在于DB中,并且在比较时出错。

挂断电话的不是'就是/哦,我在tmpComponent b/c上使用了Variant,如果我使用String,我会在Set tmpComponnent=。。。线也许这就是问题所在,只是不太确定。

这是我的代码,粗体是错误发生的地方。提前感谢您提供的任何指导。

Set rsCat = db.OpenRecordset("Categories", dbOpenDynaset, dbSeeChanges)
Dim x As Integer: x = 2
Dim LRow As Integer: LRow = ExLWb.Sheets("Categories").Cells(Rows.Count, 2).End(xlUp).Row
Dim tmpPFId As Variant, tmpCategory As Variant, tmpComponent As Variant, tmpSyntax As Variant, tmpCycle As Variant
Dim NewItem As Integer
NewItem = 0
'*******************  LOOP THROUGH SPREADSHEET UPDATING CATEGORY TABLE
For x = 2 To LRow
Set tmpPFId = ExLWs.Cells(x, 2)
Set tmpCategory = ExLWs.Cells(x, 3)
Set tmpComponent = ExLWs.Cells(x, 4)
Set tmpSyntax = ExLWs.Cells(x, 5)
Set tmpCycle = ExLWs.Cells(x, 9)
**If IsNull(DLookup("[Component]", "[Categories]", "[Component]= '" & tmpComponent & "'")) Then**
rsCat.AddNew
rsCat!PF_ID = tmpPFId
rsCat!Category = tmpCategory
rsCat!component = tmpComponent
rsCat!Syntax = tmpSyntax
rsCat!Active = True
rsCat!Available = True
rsCat!Cycle = tmpCycle
rsCat.Update
NewItem = NewItem + 1
End If
Next x

不管怎样,我想我应该选择:

如果IsNull(DLookup("[Category]"、"[CateCategory]","[Catelogy]=""">

最新更新