错误 未为 VBA 的一个或多个必需参数提供值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20629394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error No value given for one or more required parameters with VBA
提问by user3103991
I am getting "No value given for one or more required parameters", I am new in Excel VBA, Please suggest what is wrong with the query, Below is the code I am using to get the value from a access data based and I want to have the table name and the table column name on runtime.
我收到“没有为一个或多个必需参数提供值”,我是 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
rs. 打开 SQLQuery
回答by michael
Looks like a problem with this SQL query.
看起来这个 SQL 查询有问题。
"select * from " & FindString & " where [Resolution] = '" & FindString1 & "'"
"select * from " & FindString & " where [Resolution] = '" & FindString1 & "'"
I would suggest to make an extra step like this.
我建议像这样多做一步。
Dim SQLQuery as String
SQLQuery = "select * from [" & FindString & "] where [Resolution] = '" & FindString1 & "'"
rs.Open SQLQuery
Maybe you can have a look at this solution too.
也许你也可以看看这个解决方案。
No value given for one or more required parameters visual basic error