I would say the problem has to do with the fact that the term varX that you are using is enclosed within the quotations. Access cannot discern that this is a variable that you want to compare.try something like this:
"...WHERE InvoiceNumber = " & varX & ";"
I'm fairly sure this should work for...