I have 2 Combo boxes
CboD2p = Customer Title is Selected to whome goods are delivered
Cbopp = Goods Purchased from
The Following Code is Used
Private Sub CboD2p_AfterUpdate()
Dim strSource As String
strSource = "SELECT DISTINCT [PurCompanyName] " & _
"FROM Purchases " & _
"WHERE [Delivered To Party] = '" & Me.CboD2p & "' ORDER BY [PurCompanyName]"
Me.CboPP.RowSource = strSource
Me.CboPP = vbNullString
End Sub
FOR The Report following Code Is Used
Private Sub Command29_Click()
On Error GoTo Err_Handler
Const REPORTNAME = "General Purchase wo Varification"
Const MESSAGETEXT = "No Item Selected."
Dim strCriteria As String
' build string expression to filter report
' to selected customer
strCriteria = "[Delivered To Party] = """ & Me.CboD2p & """"
' make sure a customer is selected
If Not IsNull(Me.CboD2p) Then
' open report filtered to selected customer
DoCmd.OpenReport REPORTNAME, _
View:=acViewPreview, _
WhereCondition:=strCriteria
Else
MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"
End If
Exit_Here:
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_Here
End Sub
When I open the report instead of it showing me only the PurCompanyName I selected. It shows all PurCompanyName wherever Delivered To Party is
example: it shows me Delivered To Party (This Is Customer) has bought abc goods from Pepsi Company and also from Coke. Which it should only show if its bought from pepsi as only pepsi is selected and not coke because coke was not selected.
Whereas on Combo Box it separates pepsi & coke but on report it shows both of them.