Enter Parameter once for multiple parameter queries
Enter Parameter once for multiple parameter queries
(OP)
Hi all, I created a command which runs an update query and an append query. Each query requires that the user enter an input. The input is the same for each query, but because it is two different queries, access prompts to enter the same number twice. Could someone show how to code so that i only have to enter once?
Private sub command29_click()
docmd.runsql "update table set field = [ENTER] where isnull(field)"
docmd.runsql "update table1 set field1=[ ]![ ]![ ]
where (([table1].[field2]=[ENTER]))
end sub
I am new so please help. In this case I want to make it so that [Enter] only has to be entered once.
Is there a way to prompt for a variable before running the SQL and then setting [Enter] to be equal to that variable!?!?!
Thanks for any response!!
Private sub command29_click()
docmd.runsql "update table set field = [ENTER] where isnull(field)"
docmd.runsql "update table1 set field1=[ ]![ ]![ ]
where (([table1].[field2]=[ENTER]))
end sub
I am new so please help. In this case I want to make it so that [Enter] only has to be entered once.
Is there a way to prompt for a variable before running the SQL and then setting [Enter] to be equal to that variable!?!?!
Thanks for any response!!





RE: Enter Parameter once for multiple parameter queries
Get the input parameter from the user with your VB code, and then use this value in the query strings. Like the following.
CODE
Dim strInput As String
strInput = InputBox("Please enter parameter")
DoCmd.RunSQL "update Transactions set Amount = " & strInput & _
" where isnull(Amount)"
DoCmd.RunSQL "update Receipts set Checked = True" & _
" where Receipts.Amount = " & strInput
End Sub
Yeasir Rahul
Principal, VoltSmith Technologies
www.voltsmith.com