2013-12-17 63 views
1

我得到的,我在Excel VBA是新「沒有爲一個或多個必需的參數給定值」的值,請建議什麼是錯的查詢,下面是代碼我正在使用從基於訪問數據獲取值,我想在運行時擁有表名稱和表列名稱。錯誤沒有爲一個或多個必需的參數給出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

http://stackoverflow.com/questions/6034959/open-recordset-in-access-2003-2007 –

+0

http://msdn.microsoft.com/en-us/library/windows/桌面/ ms675544%28v = vs.85%29.aspx –

+0

您可以發佈您的完整代碼嗎?或者至少是這個片段所屬的'Sub'例程? :) – Manhattan

回答

-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

+0

邁克爾,感謝您的回答,但還是我用你的建議的方式得到同樣的錯誤。 – user3103991

相關問題