Hello fellow techies,
I am new to the Access genre and having a bit of trouble trying to figure out how to add in query options such as "Order BY" and "Asc" or "Desc" into the doCmd.OpenReport
here is my sub:
Code:
Private Sub ReportButton_Click()
Dim sWhere As String
Dim Order As String
Dim vars As String
If Me.Direction = "Ascending" Then
Order = " Asc"
Else
Order = " Desc"
End If
vars = "ORDER BY " & Me.SortBy & Order
sWhere = "1=1"
If Not Me.MyCat = "All" Then sWhere = sWhere & " and [Category]='" & Me.MyCat & "'"
If Not Me.CBoxOfficeNumber = "All" Then sWhere = sWhere & " and [Office_Number]='" & Me.CBoxOfficeNumber & "'"
If sWhere = "1=1" Then
DoCmd.OpenReport "EGTaxInventory", acViewPreview
Else
DoCmd.OpenReport "EGTaxInventory", acViewPreview, , sWhere, , vars
End If
End Sub
On here I have it in the OpenArgs section of the command, but that doesnt seem to work? although it doesn't error..
I tried to just add it to the end of the sWhere variable but I got a "Missing Operator" error
any help is appreciated
Bob