【发布时间】:2019-05-23 18:51:44
【问题描述】:
我正在尝试调试这个子程序,我在其中使用我在 Recordset.Find 方法中使用 InputBox 分配的变量值,但我不断收到运行时错误,因为它无法识别下面定义的变量 Prod。
我尝试将 Prod 放在单引号中,我没有收到运行时错误,但它也忽略了标准,只是给了我整个记录集中的第一项 ''''
Sub MoveAround()
'declaration of recordset variable and Prod variable
Dim MyR As Recordset
Dim Prod As String
'Setting Recordset to Current DB with Table Name and dynamic view
Set MyR = CurrentDb.OpenRecordset("813ActiveErrors", dbOpenDynaset)
'Prompts user for value of Item
Prod = InputBox("Please Input the Item")
'Finds first record in record set where Item=value of prod
'I keep getting an error here Where it says: The MS Access database engine 'does not recognize 'Prod' as a valid field name or expression
MyR.FindFirst ("[Item] = Prod")
MyR.Close
Set MyR = Nothing
End Sub
''''
【问题讨论】: