我有一个查询,您输入一个数字,您会得到一个结果(它会计算一些东西)。
现在,我有一个带有两个输入的表单。在一个输入中,您键入一个数字。输入数字后,我希望以输入值作为参数调用我的查询,然后从查询结果生成数字到第二个输入。
这是一个示例 VBA:
Private Sub Refresh_Button_Click()
Dim strSQL as String
Dim inputbox1 as String
Dim myR As Recordset
'set the input1 as a string
inputbox1 = Me.input_box_1
'this select statement creates a SQL string
strSQL = "Select whatever from table_name where field = '" & inputbox1 & "'"
'this recordset pulls your SQL statement so you can get your fields
Set myR = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
'this gives the value of your second input box
Me.input_box_2 = myR!field_you_want_to_appear
Me.Refresh
Set myR = Nothing
End Sub