I'm trying to create a button that will export the filtered records on the screen to an Excel file.
I'm using strWhere as my where string and found this code in one of the posts from this forum, but unfortunately, I can't get it output only the filtered records. It outputs all records instead.
Dim db As dao.Database, qdf As QueryDef, mySQL As String
Dim strWHERE As String
Const strSQL = "SELECT * FROM [Action Register] "
Set db = CurrentDb
Set qdf = db.QueryDefs("qryActionItems")
qdf.SQL = strSQL & "strWhere;"
Set qdf = Nothing
Set db = Nothing
DoCmd.OutputTo acOutputQuery, "qryActionItems", acFormatXLS, CurrentProject.Path & "\" & "Action Items.xls", True
I'm using strWhere as my where string and found this code in one of the posts from this forum, but unfortunately, I can't get it output only the filtered records. It outputs all records instead.
Dim db As dao.Database, qdf As QueryDef, mySQL As String
Dim strWHERE As String
Const strSQL = "SELECT * FROM [Action Register] "
Set db = CurrentDb
Set qdf = db.QueryDefs("qryActionItems")
qdf.SQL = strSQL & "strWhere;"
Set qdf = Nothing
Set db = Nothing
DoCmd.OutputTo acOutputQuery, "qryActionItems", acFormatXLS, CurrentProject.Path & "\" & "Action Items.xls", True