I was trying to edit a database using MS access macro and an error pops up saying:
The identifier '[OldPriceCodePass]' could not be found.
Please see the snapshot of the codes. I am just a beginner in using Access and not a computer programmer. Please help...
You should explicitly state the collection the variable is in:
ReturnVars!OldPriceCodePass instead of just OldPriceCodePass
Related
I'm using a database based on the MS-Access Assets Database template. (You can download it here: https://support.microsoft.com/en-us/office/use-the-access-asset-tracking-template-6e99a32c-fbda-48a2-89b0-ef0d68b381ec.
I've added a few tables of my own and some VBA code.
On the "Asset Details" form, I can make a change to the current record, then press the "Save and New" button. It runs the embedded macro cmdSaveAndNew, which you can see here:
I have not modified this macro. But it gives me this error message:
The Microsoft Access database engine cannot find the input table or query 't Asset Log'. Make sure it exists and that its name is spelled correctly
So you know, t Asset Log is the old name of one of the tables that I added to the database. I cannot figure out why the embedded macro is trying to access it. (In the current version of the database, it's tAssetLog with no spaces. I've searched through my VBA code, and it only uses the current spacing.)
I tried the macro in "Single-step" mode. As near as I can tell, the error occurs at the SaveRecord line.
I've looked at the properties of all the controls, and I don't see any Data or Events that point to t Asset Log. I've run "Compact and Repair" on the database, and also compiled the code in the VBA editor; they didn't help.
open the queries involved with this macro and sanity check that 't Asset Log' is not being used as criteria or in a calculated field...
if you don't see it there, wouldn't hurt to search in VBA for 't Asset Log' - is easily done with the Find feature...but doesn't seem like is here though not sure what the macro does....
Is there a way I can make the application MS Access and VBA more verbose in order to better diagnose errors from the IDE?
I open my MS Access project, I get a message dialog box, titled "Microsoft Visual Basic for Applications" with the message "File not found:" without any path specified. Opening the form file works as expected.
When I go into VBA, I can run some commands from the Immediate window. The following actions will make MS Access crash, showing a messaged box titled "Microsoft Access has stopped working":
Closing the database
Stopping the debugger (it opens being active, trying to load a form)
Selecting text of the procedure I was working on when MS-Access / VBA initially crashed.
This does not answer the question, but it seems the underlying problem has been fixed by deleting the procedure in question, letting MS Access crash and re-opening VBA.
To answer the question in your title: If the error is actually cause by VBA code, you can catch the error (using On Error Goto ...) and provide additional information based on the context of your method (the file you were trying to open, etc.). Unfortunately, there is no magical switch to make the built-in error messages more useful.
To answer the question in your question body: From what you describe, the error is not caused by actual user-supplied VBA code. Instead, your database or its VBA module is corrupt (Access crashing or showing seemingly random errors is a strong sign of that). Repair, compact and decompile your database. It might be worth checking out the VBA references as well, so see if any of those are missing.
can you execute the command resume in the immediate window ? it should send you back to the code line where the file was not found.
I have created an access database which is used to create reports by various people. The database simply links to various external data sources. Via macros, it runs queries, creates reports and pushes them to a SharePoint site. The macro is triggered by a button. It runs fine for me. No errors and works perfectly. For another user in my department it doesn't work. She gets the following error:
Undefined function 'Format' in expression
I looked and the macro fails on an update query that runs. See the below screenshot.
It doesn't like the "Format" portion of the expression, but only on her PC. It works fine on mine. I don't use 'Format" for any other object in my database so I'm not sure why it would error out. I use the Format function all the time to format date values.
Any idea why this is selectively erroring out on one PC?
Problem: There is Reference List in VBA. Once you open (VBA environment-> Tools-> Reference), you will find a Checked mark in front of “MISSING”.
Solution: Uncheck that check Box which says “MISSING”, and save it.
Result: It will work
Same problem but in Access 2016, I didn't have any references reported as 'Missing' but I found adding in the following reference made it work:
C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB
i have updated the old SSIS Load package. i have changed the variable names and some other stuff but when i try to execute package it gives me error for old variable names that variable not found. now i checked it so many times, i have no old variable name defined anywhere then why its giving me error for previous variable names?
Thanks
Hard to diagnose your issue without any error messages or detail, but you could view the xml (think it's View menu, then Code), and search the XML text for any instances of the old variable that is throwing the error.
Best guess is that you are referencing the old variable name in an expression somewhere. If you are allowed in your environment, download BIDS Helper. It will highlight expressions for you to make them easier to find and correct.
This is Access 2003. From an access database code module, I am opening two outside access databases and then saving the text of two forms that exist in both of the databases. I am executing the statements:
Call app1.SaveAsText(acForm, "MyForm", "c:\MyForm_app1.txt")
Call app2.SaveAsText(acForm, "MyForm", "c:\MyForm_app2.txt")
Both app1 and app2 are of type Access.Application.
I receive the error:
Method 'SaveAsText' of object ' Application' failed
This error only happens on this specific app2 form. Other forms in app2 are saving just fine. I am using Access 2003. There was a trial of Access 2007 installed but now that is removed. I am still getting the same error.
Thanks for your help. I am really puzzled over this one.
Gotta love undocumented options. For kicks and giggles, I'd try renaming one of the two forms. Or, swap the two statements and see if app1 starts erroring. It looks like the forms has identical names, perhaps Access is leaving the first one open and getting confused.
Maybe something is slightly corrupt in app2. You could always try running the /decompile option on app2 (take a backup first of course)
That form is possibly corrupt. See if you can open that form in Access and then save it under a different name. Or import the entire database into a new file.
The problem was that there is a bug in Access 2003 where it cannot handle databases converted from Access 2007 to Access 2003. The fix is to install the latest Service Pack for Office 2003.