VBA Access Error displayed but nothing in the code - vba

It's my first time using VBA and Access even if I'm coming from Angular and Swift, I'm completely lost.
I'm modifying an existing project and I have created a text label and used the expression generator, then the application crashed. I obviously think that there is a problem in the "expression" that I generated.
The problem is now that I cannot access to the Form where I was working and I get this message :
I have tried to go to the code but I haven't found my problematic expression. Do access store somewhere else the code generated, especially for the expressions generated? How can I find again my problematic expression?
In the code I found, I didn't find any object declaration, for example, as a TextBox...I tried to compile all code, since this is a syntax error, it should be easier to find and solve but it didn't work at all, the compile and run didn't show me any syntax error, I tried to change some settings to handling error but no success...
So if someone could tell me how to solve this problem. Thanks in advance.

Related

Intellisense in Access 2019

Hello all (excuse me please if I am in the wrong forum)
I have just bought MS Office Professional 2019 and am using Access 2019.
Previous versions of Access came with "intellisense" (is this what it is called?) which would highlight errors in my VBA code in a module "on the fly". That is, if I wrote a line of code that had syntax errors, the errors in the line would be highlighted. This does not seem to be switched on (or available at all) in the new Access 2019.
I have spent days looking for an answer to this, so you are my last hope. Am I missing a reference file or something?
Thanks in advance for any help you can offer.
Require Variable Declaration checked causes Option Explicit line to automatically generate in header of newly created VBA module. It does not itself cause compiler to look for undeclared variables - Option Explicit does that. For existing modules without this line, it will have to be manually added. Why MS did not make this option checked by default is a mystery.
Auto List Members unchecked disables intellisense. When checked, intellisense should work if appropriate libraries are active. Early binding must be used for declaring and setting object variables. Intellisense is not really a syntax checker, it is an aid to constructing code but does not prevent incorrect construction.
Auto Syntax Check has nothing to do with provoking intellisense. Even when unchecked, syntax errors are red highlighted, such as not using line continuation character where needed. What doesn't happen is a popup notification of error.
Thanks you everyone for your replies. The option settings suggested seem to be working now (intellisense will only look for syntax errors in known procedures or methods - if you type general rubbish there is no syntax to correct. It only does so much for you!). As to the debugger failing to break on an error, I seemed to have had the "USE ACCESS SPECIAL KEYS" checkbox (OPTIONS > CURRENT DATABASE >) unchecked, and this stopped the debugger from breaking on an error (amongst other VBA tools also denied).

Conditional Compliation Constant VB

Error BC31030 Conditional compilation constant '; ^^ ^^ EXCLUDE_CODEGEN' is not valid: Identifier expected. GpsHost C:\Projects\GpsTrackSolution\GpsHost\vbc 1 N/A
I am getting the above error when I try and build a VB.NET win forms app. I refactored it a little, updated to framework 4.7.2 and now I am getting this.
There is NO reference in ANY vbproj for that string of characters, either partial or full. I've done a find in file contents across the entire solution and cannot find that anywhere. Almost at my wit's end as to what could be doing this.
This was unrelated to VB, it was actually due to Orleans code generation trying to insert constants. Orleans isn't really designed to work with VB, so I switched to runtime codegen, instead of build time, and it worked.

Encountered Strange Error: " & ErrorName

New to VisualStudio 2015, but not to programming. Have searched both Google and here for a lead on this, but considering the available search terms, I might not immediately uncover them.
I was looking into porting an old VB6 (200k+ LoC) to VB.Net in VS2015. Mostly just poking around to determine viability. Using a project converter, and have resolved most of the initial errors, and am familiar with how the Error List works.
However, it is throwing a new one at me. It now only has two lines of error, both showing the same thing. They both say:
" & ErrorName
That's a Quote, Ampersand, and ErrorName. That's all that show up on the error list line. No file. No line number. Double click on them does nothing.
I thought perhaps the project was corrupted, so I completely re-created it, adding all the modules, forms, classes, etc again, and it found a lot more errors to fix, which I fixed, and now these two lines show up again.
Does anyone have any indication where this is coming from, or, better yet, how to fix?
I've seen VB programmers report this misbehavior before, never with a good lead to explain the problem. It is specific to VS2015, the Roslyn integration caused many issues. In general a very buggy release, be sure to apply all available Updates, currently up to Update 3. If you have a license that includes an MSDN subscription then I recommend you install VS2012, the last "good" version of VS that was not yet affected by Microsoft's new focus on agile development.
I think the underlying issue is caused by the IDE simply not parsing the compiler error message correctly. Probably having to do with the statement with the error getting quoted in the message. Getting only part of the statement text and it fumbling quotes is a pretty good hint that this is where it went wrong.
So look at the actual output of the compiler, decent odds you'll now see the full error text. Use Tools > Options > Project and Solutions > Build and Run. Change the "MSBuild output build output verbosity" setting to Normal. After the failed build, use View > Output to see the compiler output. You'll probably have a lot of messages, consider copy/pasting the content.

Visual Studio marks data type as syntax error?

Well, I've opened a solution I worked on previously (without any errors), and suddenly VB.NET finds "errors" in data types. What could possibly cause this? The code compiled before, without any syntax errors. A review by a few colleagues also didn't point out any other errors in the code. It also breaks on er in Integer, suddenly ignores End While even though they match and a whole bunch of other non-errors. I've tried re-formatting the code, reinstalling Visual Studio etc. Something in the code is causing this, but I have no idea how this is even possible.
Example 1
Example 2

Spurious "User-defined type not defined" error in Microsoft Word VBA

I have a Microsoft Word template with some code and some references, that has been working fine for months but has just started throwing up a spurious "User-defined type not defined" error whenever I open it or try to compile it.
I know it's a spurious error because I haven't made any significant changes to the code. In fact, I've rolled the code back to the last deployed version (which I know works fine) and I still get the error. I've also commented out all the code in the template and I still get the error. I've also removed and re-added all references (same error), and removed all the references and added them back, one by one, until the resultant compile errors are resolved, at which point I'm left with the spurious "User-defined type not defined" error. (I'm going to call this a UDTND error, from now, to avoid driving you all mad.) I think the error started popping up after I rebooted my PC. It only happens with this template, but I don't see how it can be anything to do with this template.
Interestingly, the error is subtly different from a genuine UDTND error in the following ways:
No code is highlighted when the error is displayed.
The dialog is titled "Microsoft Visual Basic", and contains the error message but, unlike a real UDTND error, doesn't contain the text "Compile error:";
It happens when the template is opened, not just when it's compiled (at least, I think that's different from a normal error).
I've tried Googling it but I just get a bazillion results from novice developers asking why they get this error, with responses telling them that they either need to declare the missing type, correct the spelling of the offending variable type, or add a reference to a missing library. I've been banging my head against my screen all afternoon, and that's helped about as much as all the other things I've tried (i.e. not at all). I have a feeling that this is something to do with a messed-up reference, but afaict they're all fine, and I've removed and re-added them, which I would expect to resolve that sort of problem.
Any ideas...?
Your trouble-shooting on References is sound. Once upon a time (and I don't recall the precise error) I was at the same point, and the reference ordering was the key. When you're designating References, you'll notice a "Priority" adjustment feature. Experiment with that and you may solve this.
I have had "User-defined type not defined" problem on several occasions when compiling Microsoft Visual Basic 6 (MSVB6) code that was compiling without a problem earlier. It seems to happen after I have had a long coding session without rebooting the computer. As you can guess, I have been using Microsoft operating systems. I currently am using Windows XP. Rebooting the computer usually fixes the problem as it so often does on Microsoft operating systems.
I have read that fully qualifying declarations also can help, e.g., "Dim oBar as Foo.Bar" instead of "Dim oBar as Bar". I have not tried this approach however.
I had a very similar problem.
My problem appeared (I think) just after I made a Search and Replace that I canceled (Ctrl+Z). There was not highligting of the problem, only the ""User-defined type not defined" error message when I compiled.
I tried:
1) restarting computer
2) changing reference ordering
3) removing functions/procedures, modules one at a time.
Didn't work. My project was written in Excel VBA and here was the solution I found.
THE SOLUTION:
I opened a new Excel file and opened the Visual Basic Editor. I then copied all Forms, Modules, and Class Modules one by one into the new file. I then Copied the Control Objects (3 Commandbuttons) from the old sheet into the new one. Now the new file was identical to the old project - only the ""User-defined type not defined" had gone and problem was solved.
Yea references would be the first step in troubleshooting this problem as already stated, but failing that id start commenting out the code in any event procedures running at start up (my experience is only with Access VBA though)
I had the same problem with Excel 2013.
It started when I did a search and replace on the name of a Custom Class.
I changed the name of the Class after I did the search and replace on all references to it and the spurious error started immediately after that.
I reverted to an earlier version ad confirmed that the problem was not there and then did the same search and replace and re-name and got the exact same behaviour again.
The Custom Class that I changed the name of only had one consumer and it was also a custom class.
I exported, removed and re-loaded the sole consumer class and the problem was fixed.
Check out this link for a Microsoft bug that might be related.
TLDR:
The reference to a package/addin/whatever probably needs to be re-referenced. Check Tools -> References in the Menu.
Also it appears that if you install Microsoft Security Advisory 960715, that certain controls are killed. There are fixes which may or may not work for you. A good article is on this blog:
VSOD Blog