I need to show only the records that match the criteria:
Dim stDocName As String
Dim stVal As String
Dim stWhere As String
Dim stFilter As String
stDocName = "ProformaSearch"
stVal = "='" & Me.SellerIdctrl.Value & "'"
stWhere = "[SellerId] " & stVal
stFilter = "SELECT ProformaId " & _
"FROM Proformas " & _
"WHERE OrderId = (SELECT OrderId " & _
"FROM Orders " & _
"WHERE " & stWhere & "));"
If IsNull(stFilter) Then
MsgBox "Sorry, no proformas available for this seller", vbInformation
Else
DoCmd.OpenReport stDocName, acViewPreview, , , , stFilter
End If
this is my code. I tried the stFilter on OpenArgs and on the Filter position. they both gave me the same results. they display all records instead of only those for the Seller I selected (he comes from SellerIdctrl). I also cannot use the stFilter in the 'Where' condition for opening the report. Any idea on why ti doesn't work? I want it to display only the records for one seller at a time.
Dim stDocName As String
Dim stVal As String
Dim stWhere As String
Dim stFilter As String
stDocName = "ProformaSearch"
stVal = "='" & Me.SellerIdctrl.Value & "'"
stWhere = "[SellerId] " & stVal
stFilter = "SELECT ProformaId " & _
"FROM Proformas " & _
"WHERE OrderId = (SELECT OrderId " & _
"FROM Orders " & _
"WHERE " & stWhere & "));"
If IsNull(stFilter) Then
MsgBox "Sorry, no proformas available for this seller", vbInformation
Else
DoCmd.OpenReport stDocName, acViewPreview, , , , stFilter
End If
this is my code. I tried the stFilter on OpenArgs and on the Filter position. they both gave me the same results. they display all records instead of only those for the Seller I selected (he comes from SellerIdctrl). I also cannot use the stFilter in the 'Where' condition for opening the report. Any idea on why ti doesn't work? I want it to display only the records for one seller at a time.