![](/img/trans.png)
[英]Excel-VBA SQL UPDATE Error “No value given for one or more required parameters”
[英]Error No value given for one or more required parameters with VBA
我收到“没有为一个或多个必需参数提供值”,我是Excel VBA的新用户,请提出查询的问题,以下是我用来从基于访问数据的值中获取代码的代码,在运行时具有表名和表列名。
Dim con As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim name As String
Dim count As Integer
Dim FindString As String
Dim FindString1 As String
Dim SQLQuery As String
FindString = InputBox("Enter the table name")
FindString1 = InputBox("Enter search value")
count = 4
Dim strConn As String
Set con = New ADODB.Connectioncon.Mode = adModeReadWrite
If con.State = adStateClosed Then
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & "databasepath\Database3.accdb;Persist Security Info=False;"
con.ConnectionString = strConn
con.Open
Set rs.ActiveConnection = con
End If
SQLQuery = "select * from " & FindString & " where " & FindString & ".[LOGO] ='" & FindString1 & "'"
rs.Open SQLQuery
看起来像这个SQL查询有问题。
"select * from " & FindString & " where [Resolution] = '" & FindString1 & "'"
我建议采取这样的额外步骤。
Dim SQLQuery as String
SQLQuery = "select * from [" & FindString & "] where [Resolution] = '" & FindString1 & "'"
rs.Open SQLQuery
也许您也可以看看这个解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.