I keep getting an "invalid argument in domain aggregate function" error when my form goes through this code. The code works fine if I don't use the variable QueryName, but it would be a lot easier to code if I could.
I suspect there is either something wrong with my Dim QueryName or I need to write the DMax function differently if using a variable.
Thanks for any help!
I suspect there is either something wrong with my Dim QueryName or I need to write the DMax function differently if using a variable.
Thanks for any help!
Code:
Dim QueryName
Dim Lookup1, Lookup2, a, b As Variant
QueryName = "Ni-Au-CooperSubformQuery"
Lookup1 = DMax("[ID]", QueryName)
Lookup2 = DMax("[ID]", QueryName) - 1
a = DLookup("[Ni-Au-Soft Gold Thickness Avg]", QueryName, "[ID]=" & Lookup1)
b = DLookup("[Ni-Au-Soft Gold Thickness Avg]", QueryName, "[ID]=" & Lookup2)