Access VBA type conversion failure


I get the following Access error from running the code shown in the image. What might cause this?

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
Dale FyeCommented:
Chances are you have a unique index on one of the fields in your [Invoices] table, probably the InvoiceID field.

It looks like you are trying to copy a record, if InvoiceID is a autonumber (PK) field, you will probably have to do something like:

strsql = "INSERT INTO Invoices (Field2, Field3, Field3, Field4) " _
       & "SELECT Field2, Field3, Field4 " _
       & "FROM Invoices WHERE InvoiceID = " & NZ(me!InvoiceID, 0)

Open in new window

NorieVBA ExpertCommented:

What's the value of InvoiceID when you get the error?

Where does it's value actually come from?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much. That fixed it
Dale FyeCommented:
glad to help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.