DCount problem with 2 criteria

JiTS

Ciao!
Local time
Today, 23:50
Joined
Dec 12, 2003
Messages
77
I am stuck with the function DCount...

I have the following problem:

I use:

tblContracts
============
AutoID
ContractID - numeric
Week - numeric
Price

frmContract
========
txtContractID
txtWeek
txtPrice

[Question]
I would like to check if a contractID contains Week 0 (zero).
Criteria:
Criteria one - pick contractID from text box (txtContractID)
Criteria two - 0 (for the weeknumber 0)

[Own Solution]
I am using DCount for this check:

Code:
If DCount("[txtWeek]", "tblContracts", "[ContractID] = " & Me.txtContractID & "and [Week] =" & 0) then ...

What's wrong in this code?!?

JiTS
 
If tblContracts is the table you are searching, then the first DCount parameter must be a field in that table. In this case, you'll want to count on Week or Contract ID.

DCount("[ContractID]", "tblContracts", "[ContractID] = " & Me.txtContractID & "and [Week] = 0")

You don't need to separate out the final 0 from the the string "and [Week] =" since you're passing it a literal value that isn't being referenced by pointing to a form field.
 
Still going with week numbers, eh? :(
 
Mile-O-Phile: yes

I asked my manager what he wants to fill in and he said the weeknumbers because he don't want to fill in dates.

For example:
He knows that the prices for week 1, 4 and 6 are $ 1, without knowing the exact date. The price is for monday thru friday.

That's the story behind the weeknumbers... sleep tight now... ;)

BTW For tomorrow... HAPPY VALENTiNE... enjoy! :p
 
Last edited:

Users who are viewing this thread

Back
Top Bottom