You'll need to put that code in your form OnCurrent event procedure. Did you do this?
A better way would be to create a join query that joins your form data with the invoice amount. Then use this query as your form recordsource. When you do this, the invoice amount is automatically looked up and Dlookup is not needed.