The problem arises in the transactions = line. If I change that line to read:
transactions = DCount("[Datum]", "All_Inventory_2006", "[Datum] >= #" & inputData & "/01/2006#") the function runs properly and returns the correct result (Count of entries with date xx/01/2006 or above. However, adding the And "[Datum] <= #" & inputData & "/31/2006#" at the end of the code gives a syntax error. I'm very new to VB and haven't quite figured out the proper syntax to make this work. Any help would be greatly appreciated.
However, when I try to implement the Year([Datum]) function as well, I keep getting a type mismatch error. The Datum field is in Date/Time and the inputData and inputData2 variables are both As String.
Any ideas how I could get this code to work without type mismatch error?
Your placement of quotes and ampersands is not correct. You might want to revisit them, keeping in mind the need to separate components of the criteria from variables to be concatenated into that structure. Perhaps this will be of some assistance: