Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I didn't know where went wrong. When i select View All in both the combo box, it appear the data that i want. Yet if when i change the variable of the CateName and View All in the FormSelection, the data appear all, which is not what i need. Anyone can tell me where when wrong?
Option Compare Database
Option ExplicitPrivate Sub Command10_Click()
Dim choice As String
If (FormSelection.Value = "Vendor") Then
choice = "A"
ElseIf (FormSelection.Value = "Inhouse") Then
choice = "B"
ElseIf (FormSelection.Value = "Japan") Then
choice = "C"
End IfOn Error GoTo Err_Command10_Click
Dim stDocName As String
stDocName = "ProductRpt"'>> Total of 4 combinations <<
'Category Name = view all Form Selection = view all
If (CateName.Value = "View All" And FormSelection.Value = "View All") Then
DoCmd.OpenReport stDocName, acPreview'Category Name = view all Form Selection != view all
ElseIf (CateName.Value = "View All" And FormSelection.Value <> "View All") Then
DoCmd.OpenReport stDocName, acPreview, , "FormSelection =" & choice'Category Name != view all Form Selection = view all
ElseIf (CateName.Value <> "View All" And FormSelection.Value = "View All") Then'Category Name! = view all Form Selection != view all
DoCmd.OpenReport stDocName, acPreview, , "CateName ='" & CateName.Value & "'"
Else
'rest is CateName and FormSelection
DoCmd.OpenReport stDocName, acPreview, , "CateName ='" & CateName.Value & _
"' FormSelection = " & choice
End If
Exit_Command10_Click:
Exit SubErr_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_ClickEnd Sub
Private Sub FormSelection_AfterUpdate()
'not one of the choice in DDL
'not view not outstanding not completed
If (FormSelection.Value = "View all") Then
ElseIf (FormSelection.Value = "Vendor") Then
ElseIf (FormSelection.Value = "Inhouse") Then
ElseIf (FormSelection.Value = "Japan") Then
Else
FormSelection.Value = "View all"
End If
End Sub

View All.
I've solved the top of the error alr. Would you mind seeing if
these coding got error?DoCmd.OpenReport stDocName, acPreview, , "ProductCat ='" & ProductCat.Value & _
"FormSelection ='" & FormSelection.Value & "'"Becos it keep saying Syntax Error(missing operator) in query expression
Thanks for your reply btw. (:

That would do it, but you also need some sort of relation between the two conditional statements.
"ProductCat ='" & ProductCat.Value _ "' AND FormSelection ='" & FormSelection.Value & "'"

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |