I am using the onclick() event of a button to open up a second form. The second form is based off a query (hypothetical) let's say the query is
Code:
select * from employeedata
now I want to be able to add a where clause and a parameter to the syntax based off a button press. If my button press event looks like this
Code:
Private Sub cmdbtn1_Click()
Dim stDocName As String, stLinkCriteria As String, Dim WC As String
stDocName = "frmTest"
set WC = "Nancy"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
So based off the above I would want to modify the query the form is based on to be
Code:
Select * from employeedata where employeename = WC
There will always be a parameter passed from the button click event. What is the proper way to set this up in a button click event?
EDIT ------
Or would it be easier to pass a vba variable to the where clause of onload() event of the form, as opposed to altering a query?