What is wrong w/my DCOUNT statement?

wcboyd

Registered User.
Local time
Yesterday, 18:43
Joined
Aug 30, 2004
Messages
50
Hello All,

I have the following DCOUNT statement:

MsgBox "Item count found = " & DCount("[ItemID]", "tblItems", "[ItemID] = [ItemFnd]")

Where ItemID = Primary Key on table tblItems
ItemFnd = a long Integer variable that gets populated programatically, not from the form. It is internal to the function.

I get the following error:

Run-time error '2471'
The expression you entered as a query parameter produced this error: 'The object doesn't contain the Automation object 'ItemFnd."

I can hard code a value and I do not get the error. When I watch the variable I can tell it has a valid value.

Any ideas what I am doing wrong?

Thanks,
 
Craig,

MsgBox "Item count found = " & DCount("[ItemID]", "tblItems", "[ItemID] = " & ItemFnd)

Wayne
 
Woo-hoo! That did it!

Thanks Wayne!
 
OK, now I am trying to tack an "AND" to the end of the selection so it would look like :

MsgBox "Item count found = " & DCount("[ItemID]", "tblItems", "[ItemID] = " & ItemFnd AND [EffDate] <= [txtDate])

Where [EffDate] is a field on the record from the [ItemID] and
[txtDate] is an unbound text box from the form. Needless to say I can not get the above statement to behave. Any thoughts?

Thanks!
 
Craig,

Go figure ...

Code:
MsgBox "Item count found = " & DCount("[ItemID]", "tblItems", "[ItemID] = " & ItemFnd & " AND [EffDate] <= #" & [txtDate] & "#")

Wayne
 
Yet again, thanks.

I am about 99% sure I would not have figured that one out.

Craig
 

Users who are viewing this thread

Back
Top Bottom