当导入Excel工作表以使用VBA访问时,如何克服单元格中的斜杠导致运行时3075
找到了一篇关于这个问题的类似文章,但它使用的是SQL查询,而我使用的是DLookup。 我正在导入Excel工作表以访问。 我正在获取运行时3075-语法错误(缺少运算符)…'[Component]=“没有/想要一辆车”。 该特定组件已经存在于数据库中,并且在比较时出错 是'或/导致了挂断 哦,我在tmpComponent b/c上使用了Variant,如果我使用String,我在设置tmpComponent=。。。线路。也许这就是问题所在,只是不太确定 这是我的代码,粗体是错误发生的地方。 提前感谢您提供的任何指导当导入Excel工作表以使用VBA访问时,如何克服单元格中的斜杠导致运行时3075,excel,vba,import,dlookup,Excel,Vba,Import,Dlookup,找到了一篇关于这个问题的类似文章,但它使用的是SQL查询,而我使用的是DLookup。 我正在导入Excel工作表以访问。 我正在获取运行时3075-语法错误(缺少运算符)…'[Component]=“没有/想要一辆车”。 该特定组件已经存在于数据库中,并且在比较时出错 是'或/导致了挂断 哦,我在tmpComponent b/c上使用了Variant,如果我使用String,我在设置tmpComponent=。。。线路。也许这就是问题所在,只是不太确定 这是我的代码,粗体是错误发生的地方。 提
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
不管怎样,我想我应该跟你一起去: 如果为null(DLookup(“[Category]”、“[Categories]”、“[Categories]=”&tmpCategority&“&[Component]=”&tmpComponent&”),则