View Full Version : What is wrong w/my DCOUNT statement?


wcboyd
07-05-2005, 11:51 AM
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,

WayneRyan
07-05-2005, 12:01 PM
Craig,

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

Wayne

wcboyd
07-05-2005, 12:08 PM
Woo-hoo! That did it!

Thanks Wayne!

wcboyd
07-05-2005, 12:56 PM
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!

WayneRyan
07-05-2005, 06:16 PM
Craig,

Go figure ...


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


Wayne

wcboyd
07-06-2005, 02:28 AM
Yet again, thanks.

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

Craig