The DCOUNT Function

atrium

Registered User.
Local time
Today, 22:17
Joined
May 13, 2014
Messages
348
I tried this and I just keep getting problems with it Error message attached

Me.TotNoForSaleFld = DCount("VehicleId", "Vehicles", "[BuyerId] = 0 And [ClientId] = " & Me.ClientsIdFld)



Any Help wou;r be appreciated
 

Attachments

  • Capture.PNG
    Capture.PNG
    5.2 KB · Views: 115
Try:
Me.TotNoForSaleFld = DCount("VehicleId", "Vehicles", "[BuyerId] = 0 And [ClientId] = " & Me.ClientsIdFld & ")
 
Me.TotNoForSaleFld = DCount("VehicleId", "Vehicles", "[BuyerId] = 0 And [ClientId] = " & Me.ClientsIdFld)

If Me.ClientsldFld is text then your quoting is what is whacking you.

Code:
Me.TotNoForSaleFld = DCount("VehicleId", "Vehicles", "[BuyerId] = 0 And [ClientId] = '" & Me.ClientsIdFld & "'")

Take a careful look at the quoting, recognizing a mix of double-quotes and single-quote/apostrophe.
 
Are you sure that BuyerID is spelled correctly? Also, the DLookup() as it is coded will count only non-null vehicleID's. This may or may not be what you want. The following version will count all the rows returned by the criteria.

Me.TotNoForSaleFld = DCount("*", "Vehicles", "[BuyerId] = 0 And [ClientId] = " & Me.ClientsIdFld)
 

Users who are viewing this thread

Back
Top Bottom