Access VBA type conversion failure

Hi

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

1
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

0
 
NorieVBA ExpertCommented:
Murray

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

Where does it's value actually come from?
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much. That fixed it
0
 
Dale FyeCommented:
glad to help
0
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.