I am trying to use the following criteria in an if statement in a macro: [TempVars]![VarID]=DMin("ID","tblInventoryItemTransactionsSorted","[tblInventoryItemTransactionsSorted].[Name]='" & [tblInventoryItemTransactionsSorted].[Name] & "'") where VarID is a temporary variable that is set to the ID of the current record, and DMin calculates the smallest ID number for any set of records with the same Name in the record set. The value that DMin will return is actually in a field in the table but I am unable to use in the If statement so I use the domain function to calculate it again. The problem is that I keep getting the following error message "Microsoft Access cannot find the name 'tblInventoryItemTransactionsSorted' you entered in the expression.". The DMin function as written above works fine in a query. Any suggestions would be appreciated.