I have a form that provides my users with a summary of vacation time (Associate Summary). I also have a report that generates the summary information in report format for email
Use the OpenReport
method's WhereCondition
parameter to filter the report's record source.
So, assuming the form has a text box named txtUserName
and the report's record source includes a field named user_name
, use something like this in your command button's click event procedure:
DoCmd.OpenReport "YourReportName", _
WhereCondition:="user_name='" & Me.txtUserName & "'"
Actually you can make troubleshooting easier by using a string variable to hold WhereCondition.
Dim strWhere AS String
strWhere = "user_name='" & Me.txtUserName & "'"
Debug.Print strWhere ' <-- use Ctrl+g to open Immediate window and view this
DoCmd.OpenReport "YourReportName", WhereCondition:=strWhere