This usually implies that it cannot find a field based on what it is told. Is there acutally a field called Invoicenumber?
You can also reduce the sql to
Code:
sql = "SELECT * FROM Invoices WHERE Invoicenumber=" & rep & ";"
This is assuming that rep is number and not a string, if it is a string you need to code it as follows
Code:
sql = "SELECT * FROM Invoices WHERE Invoicenumber='" & rep & "';"
Also I would introduce some validation, such as
Code:
If Rst.EOF = True And Rst.BOF = True Then
MsgBox "Invoice number " & rep & " does not exist!"
Set Rst = Nothing
Set db = Nothing
Exit Sub
End If
David