+ Reply to Thread
Results 1 to 3 of 3

Illogical error messages from Excel VBA Compiler

  1. #1
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Illogical error messages from Excel VBA Compiler

    I have just encountered some strange (illogical) error messages from the VBA compiler. I know that it's right, and I'm wrong, but I can't figure out how or why.

    I have a Form (frmPrimaryPerson), and an instance of a Class (Form. I am loading data from the Form fields into the Object. This takes a fai bit of time, because there areseveral segments to the form. At onepoint, however, I have the following chunk of code (buried within a With FormPerson/End With bracket) Situation 1:

    Please Login or Register  to view this content.
    This code produces an error message: Method or data-member not found, and highlights chkVegan. OK, must have messed up the definition of chkVegan in the form. But wait, this example is from line 648 of the form module. Somewhat earlier (line 425, the following code does not produce an error:

    Please Login or Register  to view this content.
    So the first appearance of chkVegan, a couple of hundred lines of code earlier does not produce a n error, but the later version does.
    A quick search for all instances of chkVegan produces no separate declaration from its inclusion in the form. IOW, it's not a missing member

    Perhaps commenting out the clause with the chkVegan in it will help. This code (Situation 2) produces a different error message:
    Please Login or Register  to view this content.
    produces a blunt "Syntax error" message. OK, maybe commenting out a single clause from a compound condition doesn't work. Let's try deleting the offending line (Situation 3):

    Please Login or Register  to view this content.
    This produces the same error message as before (Method or data-member not found), but it is now pointing one line earlier than it was before, to chkVegetarian ???!!!

    Now, I can understand it if it pointed one line later (to make up for the missing line, but it 'approved' the chkVegetarian on the first go round. Why is it complaining now?

    As I said, I know it's in my code, but I can't,for the life of me, figure out where, or why.

    I've attached the whole of the 'container' procedure here:

    Please Login or Register  to view this content.
    And there is a file attached which contains the whole kit and caboodle. It must be a subtle thing, but at the very least the compiler messages are not helpful!

    Any thoughts, comments, ideas gratefully accepted!

    Tony
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Illogical error messages from Excel VBA Compiler

    There are a few errors, but oddly those aren't among them. You have Me.GlutenIntolerant and Me.LactoseIntolerant, neither of which is correct, and you have me.txtotherdietarydescription when it should be txtotherdietaryrestriction
    Rory

  3. #3
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    286

    Re: Illogical error messages from Excel VBA Compiler

    Thanks, Corya,

    I guess taking a few weeks away from the problem didn't clear my mind as much as I hoped. However, following your suggestions, it seems that the compiler is still flagging the error on the wrong line.

    In all fairness, there's probably a variable saying StartOfCurrentSymbol, or something like that, and if it's not declared as part of the recursive goal-searching proceure(parseExpression, parseClause, parseStatement) or whatever, or at least passed in to those procedures as a parameter, then we can easily lose track of the 'proper'place to flag an error. At the start of the if statement, we are searching for ConditionalExpression, which leads to searching for a Condition, but we encounter a LeftParen, and so we should pass the new value (in this case 2 characters further along) into the new search. In this particuloar case we have a search sequence something like:

    ConditionalExpression
    LeftParenthesis
    COnditionalExpression
    Term
    Relop
    Term
    Rparenthesis
    ConditionCOnnector
    LeftParenthsesis
    ConditionalExpression
    Term
    ConditionConnector
    Term
    Relop
    Term <== Here is where the error was
    RightParenthesi
    RightParenthesis

    and so on
    By the time we get to the fourth term (or, indeed, the 8th, `12th, 16th and so on) we have moved down at least one line, and to a different position in that line.

    Obviously I don't know how the VBA compiler works in detail, but this is the first level enhancement to the Mini-Pascal Compiler described in Wirth, Algorithms + Data Structures= Programs.

    Thanks for your eagle eyes. This board is fantastic!

    Solved,

    Tony

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 16
    Last Post: 04-23-2015, 06:41 AM
  2. Compiler Error on End Sub in If stmt
    By dmqueen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2014, 03:33 PM
  3. VBA Compiler error- Excel 2010
    By kt090678 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-07-2014, 09:10 AM
  4. Creating Error Messages in MS Excel
    By Mike87 in forum Excel General
    Replies: 11
    Last Post: 04-21-2008, 06:44 PM
  5. excel closing - no error messages
    By kollin in forum Excel General
    Replies: 1
    Last Post: 08-17-2007, 03:00 PM
  6. Compiler Error
    By vba-lover in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-15-2007, 10:22 PM
  7. [SOLVED] Help with compiler error
    By Pank Mehta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2005, 08:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1