Access VBA script stopped working.

I have an Access (2016) database that used to work when I clicked on a button it would export the data to an Excel spreadsheet. I created the commands in Access's VBA (I am not a VBA programmer) however now when I try to run (click on the button), I get the following error "Compile error: Can't find project or library. Here is the VBA code that I am using:

strSQL = "SELECT * FROM " & "Table_ExpenseReport" & " WHERE " & "[ID] = " & ID & ";"

It is showing that the error is on the ID part. I want this to pull the data in the ID field (cell) in the Access database and keep it as the rest of the command sends that ID's data to the Excel spreadsheet and only that ID's data. Can someone help me? I am more than happy to attach screenshots, etc. to make this work again.
Phil TukeyNetwork AdministratorAsked:
Who is Participating?
NorieVBA ExpertCommented:

In the VBE goto Tools>References... and look for anything marked as MISSING.

If you find anything take a note of its name and uncheck it.

Once you've finished close down the database, saving anything you are prompted to save.

Re-open the database and try the button again.
Dale FyeCommented:
to expand on Norie's comment.

After unchecking the item that is "MISSING" in the refernces, you will need to look through the remaining references and see if you can find a "similar" reference.

For example, you might see a reference for "Microsoft Excel 14.0 Object Library".  If that item is missing, scroll through the rest of the items in the list box and search for "Microsoft Excel ##.0 Object library", where the ## represents any number that is in the list.  If you find it, select that item and close your references, then try to compile your application.

Phil TukeyNetwork AdministratorAuthor Commented:
Thank you both, I was able to locate a "Missing" reference, removed the check mark, and restarted Access. That took care of the problem.
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.