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:
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:
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:
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):
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:
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
Bookmarks