Hi Karl,
Thanks for the speedy reply. As your signature states “Build a little, test
a little.†Below is what I’ve been building.
Private Sub Command13_Click()
Dim myFilter As String
'ALL
If Me.OptInv = 1 And Me.OptQuote = 1 And Me.OptHeld = 1 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Invoiced' OR [BookingStatus] = 'Quote' OR
[BookingStatus] = 'Held' OR [BookingStatus] = 'Invoice/Cancelled' OR
[BookingStatus] = 'Deleted' OR [BookingStatus] = 'Deleted/Cancelled')"
End If
'NO INVOICED
If Me.OptInv = 0 And Me.OptQuote = 1 And Me.OptHeld = 1 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Quote' OR [BookingStatus] = 'Held' OR
[BookingStatus] = 'Invoice/Cancelled' OR [BookingStatus] = 'Deleted' OR
[BookingStatus] = 'Deleted/Cancelled')"
End If
'NO QUOTE
If Me.OptInv = 1 And Me.OptQuote = 0 And Me.OptHeld = 1 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Invoiced' OR [BookingStatus] = 'Held' OR
[BookingStatus] = 'Invoice/Cancelled' OR [BookingStatus] = 'Deleted' OR
[BookingStatus] = 'Deleted/Cancelled')"
End If
'NO HELD
If Me.OptInv = 1 And Me.OptQuote = 1 And Me.OptHeld = 0 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Invoiced' OR [BookingStatus] = 'Quote' OR
[BookingStatus] = 'Invoice/Cancelled' OR [BookingStatus] = 'Deleted' OR
[BookingStatus] = 'Deleted/Cancelled')"
End If
'NO INVOICE/CANCELLED
If Me.OptInv = 1 And Me.OptQuote = 1 And Me.OptHeld = 1 And Me.OptInvCan = 0
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Invoiced' OR [BookingStatus] = 'Quote' OR
[BookingStatus] = 'Held' OR [BookingStatus] = 'Deleted' OR [BookingStatus] =
'Deleted/Cancelled')"
End If
'NO DELETED
If Me.OptInv = 1 And Me.OptQuote = 1 And Me.OptHeld = 1 And Me.OptInvCan = 1
And Me.OptDel = 0 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Invoiced' OR [BookingStatus] = 'Quote' OR
[BookingStatus] = 'Held' OR [BookingStatus] = 'Invoice/Cancelled' OR
[BookingStatus] = 'Deleted/Cancelled')"
End If
'NO DELETED/CANCELLED
If Me.OptInv = 1 And Me.OptQuote = 1 And Me.OptHeld = 1 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 0 Then
myFilter = "([BookingStatus] = 'Invoiced' OR [BookingStatus] = 'Quote' OR
[BookingStatus] = 'Held' OR [BookingStatus] = 'Invoice/Cancelled' OR
[BookingStatus] = 'Deleted')"
End If
'NO INVOICED OR QUOTE
If Me.OptInv = 0 And Me.OptQuote = 0 And Me.OptHeld = 1 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Held' OR [BookingStatus] =
'Invoice/Cancelled' OR [BookingStatus] = 'Deleted' OR [BookingStatus] =
'Deleted/Cancelled')"
End If
'NO INVOICED OR QUOTE OR HELD
If Me.OptInv = 0 And Me.OptQuote = 0 And Me.OptHeld = 0 And Me.OptInvCan = 1
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Invoice/Cancelled' OR [BookingStatus] =
'Deleted' OR [BookingStatus] = 'Deleted/Cancelled')"
End If
'NO INVOICED OR QUOTE OR HELD OR INVOICE/CANCELLED
If Me.OptInv = 0 And Me.OptQuote = 0 And Me.OptHeld = 0 And Me.OptInvCan = 0
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Deleted' OR [BookingStatus] =
'Deleted/Cancelled')"
End If
'NO INVOICED OR HELD OR INVOICE/CANCELLED
If Me.OptInv = 0 And Me.OptQuote = 1 And Me.OptHeld = 0 And Me.OptInvCan = 0
And Me.OptDel = 1 And Me.OptDelCan = 1 Then
myFilter = "([BookingStatus] = 'Quote' OR [BookingStatus] = 'Deleted' OR
[BookingStatus] = 'Deleted/Cancelled')"
End If
If cboDepMonth = "<ALL>" Then
myFilter = myFilter & "AND [Division] =
[Forms]![frmGen1_2SalesByDivisionV2]![cboDivision] AND [YOD] =
[Forms]![frmGen1_2SalesByDivisionV2]![cboDepYR]"
Else
myFilter = myFilter & "AND [Division] =
[Forms]![frmGen1_2SalesByDivisionV2]![cboDivision] AND [YOD] =
[Forms]![frmGen1_2SalesByDivisionV2]![cboDepYR] AND [MODName] =
[Forms]![frmGen1_2SalesByDivisionV2]![cboDepMonth]"
End If
DoCmd.OpenReport "rptGen1_2SalesByDivision", acViewPreview, , myFilter,
acWindowNormal
End Sub
The above works, but I’ve not covered all selection possibilities.
I can’t believe there isn’t a better way?
KARL DEWEY said:
Here is a different method. Use Option Group and two field table.
Select option and DLookup pulls corresponding status from table.
--
Build a little, test a little.
h2fcell said:
Hello,
I have a report that list all orders for the year. The orders report
includes a Status column and an order could have one of six possible status.
Quote
Held
Invoiced
Invoiced/Cancelled
Deleted
Deleted/Cancelled
The users have asked to get a form with six option buttons they can toggle
to choose which status conditions they want to include or exclude on the
report. I have created the form with the six option buttons with “Default
Value†property set to 1 and a Next button to run the report. I’m blanking
out tryiing to build the nested If statement. Any examples would be great.
Or should I be using a Select Case?
Private Sub Command13_Click()
Dim myFilter As String
If Me.OtpInv = 1 Then
myFilter = "([OrderStatus] = 'Invoiced' )"
Else
End If
‘or should I use a CASE
DoCmd.OpenReport "rptGen1_2SalesByDivision", acViewPreview, , myFilter,
acWindowNormal
End Sub