Most of the code won't isn't applicable for what you are trying to do.
The SQL of the query "StaffDivision" should be:
SELECT QueryLog.QueryID, QueryLog.AQPQNumber, QueryLog.RerunID, QueryLog.[Customer Name], QueryLog.[Description], QueryLog.[Date approved], QueryLog.[Codes Used], QueryLog.[Staff Division], QueryLog.[Department/ Business], QueryLog.[Date Received], QueryLog.[Received by], QueryLog.[Confidentiality] FROM QueryLog
Notice that there is not a WHERE clause. The "ORDER BY" clause is not needed because the sort order in a report is set within the report.
The recordsource for the form should be the query "StaffDivision".
The code for the button that opens the report should be:
Code:
Private Sub BUTTON_NAME_Click()
On Error GoTo Err_Staff_Division_Click
Dim stDocName As String
Dim stLinkCriteria As String
'this is the report name
stDocName = "Queries by Staff Division"
'this is the criteria (the WHERE clause)
If Len(Trim((Me.[Staff Division] & "")) > ) then
stLinkCriteria = "[Staff Division] Like '" & Me.ListDivision & "'"
End If
DoCmd.OpenReport stDocName, acPreview,, stLinkCriteria
Exit_Staff_Division_Click:
Exit Sub
Err_Staff_Division_Click:
MsgBox Err.description
Resume Exit_Staff_Division_Click
End Sub
I can't tell if "[Staff Division]" is text or a number; if "[Staff Division]" is a long, the line should be:
Code:
stLinkCriteria = "[Staff Division] = " & Me.ListDivision