Reputation: 6006
I have a query that you enter a number, and you get a result (it calculates something).
Now, I have a form with two inputs. In one input you type a number. After you type the number, I want my query to be called with the input's value as an argument, and then generate the number from query's result to the second input.
Upvotes: 0
Views: 998
Reputation: 903
Here's an example 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
Upvotes: 1