我得到“没有给出一个或多个必需参数的值”,我是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
答案 0 :(得分:-1)
这个SQL查询看起来有问题。
"select * from " & FindString & " where [Resolution] = '" & FindString1 & "'"
我建议像这样做一个额外的步骤。
Dim SQLQuery as String
SQLQuery = "select * from [" & FindString & "] where [Resolution] = '" & FindString1 & "'"
rs.Open SQLQuery
也许你也可以看看这个解决方案。
No value given for one or more required parameters visual basic error