字符串查询无法执行

String Query cannot be executed

嘿,

我正在编写可以从 Excel 传输数据并将其记录在 Access 数据库中的代码。我目前的代码是从一个网站复制的,并更改了与我的工作表有关的值和一些声明。但问题是,我无法 运行 我的代码,但我从其他网站获得的文件能够 运行 成功。你能解释一下我的代码中的问题是什么吗?这是代码:

Sub Customer Log()
Dim cn as Object
Dim strQuery as string
Dim custName As String
Dim ordID As String
Dim myDB As String

'Initialize Variables
custName = Sheets("Batch_Report").Range("D4").Value
ordID = Sheets("Batch_Report").Range("D5").Value

'Database Location
myDB = "C:\Users\intern.maxvue\Dekstop\Adhariah (Intern)\Bar Code System\ReviewReport_v1_2015.accdb"
Set cn = CreateObject("ADODB.Connection")

With cn
    .Provider = "Microsoft.ACE.OLEDB.12.0"    'For *.ACCDB Databases
    .ConnectionString = myDB
    .Open
End With

strQuery = "INSERT INTO CustomerLog ([CUSTOMER NAME], [ORDER ID]) " & _
           "VALUES (""" & custName & """, " & ordID & "); "

cn.Execute strQuery
cn.Close
Set cn = Nothing
End Sub

当我调试并且行到达 cn.Execute strQuery 时,"run-time error: no value given for one or more required parameters" 弹出。

提前致谢。

尝试:

strQuery = "INSERT INTO CustomerLog ([CUSTOMER NAME], [ORDER ID]) " & _
           "VALUES ('" & custName & "', " & ordID & ")"