DoCmd.OpenReport

newbE

Registered User.
Local time
Today, 01:07
Joined
Mar 3, 2014
Messages
12
I have a table, tblCustomers, where the command button cmdShowLots resides. I have created a report that shows each Customers/Owners lot information from tblLots. I am trying to filter the report to include only the lot information for the current customer/owner and to display a msgbox if the customer does not have a lot. As you can see I am currntly getting the entire list. Help with code to filter results please! Thank you!:confused:

Code:
Private Sub cmdShowLots_Click()
  Dim varX As Variant
  varX = DLookup("fldOwnerID", "tblLots", "fldOwnerID=" & Me.fldCustomerID)
  If IsNull(varX) Then
    MsgBox "This Customer does not own a lot."
  Else
    DoCmd.OpenReport "rptCustomerLots", acViewPreview
    DoCmd.RunCommand acCmdZoom150
  End If
End Sub
 
look at the other parameters for openreport.

One of them is for the WHERE condition which from your code would presumably be

"fldOwnerID=" & Me.fldCustomerID
 
After changing the code I am getting the first field of the form (same information) for every customer. Any thoughts about that?
 
... And the IsNull is no longer working when using the wherecondition.
 
After closing the form and reopening it... it is now working. Thank you.
 
without knowing what you have changed the code to, no
 

Users who are viewing this thread

Back
Top Bottom