繁体   English   中英

错误VBA没有为一个或多个必需参数给出值

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM