I'm trying to create an inventory tracking form (well not exactly, but its best described as that). I'm using a simple dcount function to count records in the Scheduled Invoices query with certain criteria. My problem is, I am trying to use an IIF function in part of the dcount criteria. First of all is this possible. Second, if so, I cant seem to get it right. Here first is s verbal explination of what I'm counting (the criteria)...
count all where the delivery day = "past"
and Pickup Day <> "past"
and size = itemSize -----> itemSize is a variable received from the value of the item on the invoice
The tricky part is as follows... The Itemsize varialbe could be one of 6 possibilities. If size = 10, 15, 20, or 30, then the criteria would be just Size = itemsize, but if the itemSize Variable = "Concrete" or "Stumps" I need to look in the item description for the Itemsize and add, the literal term, where description includes 10, 15, 20, or 30.
The VBA code I came up with is as follows but does not work... Gives error "Argument not Optional"
the '20' above would also be a variable getting its value form the control calling the function, but for sake of this question lets just keep it as a constant for now
Does anyone see anything wrong with this expression, or is it that I just cant use the IIF within the criteria of a Dlookup?
count all where the delivery day = "past"
and Pickup Day <> "past"
and size = itemSize -----> itemSize is a variable received from the value of the item on the invoice
The tricky part is as follows... The Itemsize varialbe could be one of 6 possibilities. If size = 10, 15, 20, or 30, then the criteria would be just Size = itemsize, but if the itemSize Variable = "Concrete" or "Stumps" I need to look in the item description for the Itemsize and add, the literal term, where description includes 10, 15, 20, or 30.
The VBA code I came up with is as follows but does not work... Gives error "Argument not Optional"
Code:
DCount("*", "[Scheduled Invoices]", [Delivery Day] = "past" _
& "and [Pickup Day] <> 'past'" _
& IIf([Scheduled Invoices]![Size] <> "Concrete Load" Or [Scheduled Invoices]![Size] <> "Stumps", " and [Size] ='" & itemSize & "', " and InStr([Scheduled Invoices]![[Description], [COLOR=red]'20'[/COLOR])>0)"))
the '20' above would also be a variable getting its value form the control calling the function, but for sake of this question lets just keep it as a constant for now
Does anyone see anything wrong with this expression, or is it that I just cant use the IIF within the criteria of a Dlookup?