0
我對MS Access和VBA比較陌生。我試圖爲這個數據庫做一些代碼,並得到錯誤消息'運行時錯誤3061.太少的參數。預期1「,當它到達OpenRecordSet子句運行時錯誤3061 - ms訪問
我一直在研究,看着這幾天,但無法找出錯誤的原因我知道錯誤是在SELECT特別是在WHERE子句時形式被關閉。
奇怪的是,當我改變條件Record_Num = 2或似乎工作的任何具體的數字,但我需要使用Record_Match_Temp變量。
任何幫助將不勝感激。在此先感謝。這裏是代碼
Option Compare Database
Dim Record_Match_Temp As Integer
Dim Logged_Now As String
Private Sub Form_Close()
Dim db2 As Database
Dim rs2 As Recordset2
Dim SelStr As String
Set db2 = CurrentDb()
SelStr = "SELECT Record_Num FROM User_Log WHERE Record_Num = Record_Match_Temp"
Set rs2 = db2.OpenRecordset(SelStr)
End Sub
Private Sub Form_Load()
Form_User_Name = Environ("UserName")
Logged_Now = Now()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Select * from [User_Log]")
rs.AddNew
rs![Log_User_Name] = Environ("UserName")
rs![Logged_Computer] = Environ("ComputerName")
rs![Logged_In] = Logged_Now
rs![Record_Match] = rs![Record_Num]
Record_Match_Temp = rs![Record_Num]
' rs![Logged_Out] = Now()
rs.Update
End Sub
Private Sub Form_Timer()
Date_Time.Requery
End Sub
太好了。非常感謝。我現在沒有收到錯誤消息。 Altought是誠實的,我不明白,因爲我讀的所有文獻都沒有指出任何關於&的內容。對此,我真的非常感激。再次感謝 –