Strange Error Message - Member not found.

yhgtbfk

Registered User.
Local time
Tomorrow, 00:15
Joined
Aug 30, 2004
Messages
123
I have a program that works perfectly.

It is in use, so I have done modifications on another copy of it. Tomorrow morning I want to copy those forms across.

I did a trial run and I get an unusual error:

"The expression OnActivate you entered as an event property setting produced the following error: Member already exists in an object module from which this object module derives"

By running the debugger it highlights:

Option Explicit

Dim BackR As Integer 'The user's red colour
Dim BackG As Integer 'The user's green colour
Dim BackB As Integer 'The user's blue colour
-->HERE Dim textcolour As Integer 'The user's text colour

Now the strange thing is, that if I take it out of the Option explicit, and paste it within the OnLoad module (where I get the user's colours), then I get no error message.

And the stranger thing is, I did not change ANY code when I modified the form, I only added a few controls, none of which are remotely like 'textcolour'.

So why does it work on the other version, but not here?
 
that if I take it out of the Option explicit, and paste it within the OnLoad module {edited},then I get no error message.

This is the flare-lit tip-off, you have a scoping problem.

Member already exists in an object module from which this object module derives

Depending on where you define things, they are either global or local. In the options area, you definition is module-local but subroutine-global. I.e. all members of the class module can see it, though as part of a class module, no other module can see the item.

I only added a few controls, none of which are remotely like 'textcolour'.

When you added a control, you added ANOTHER class of global object that also has a name. I'm going to suggest that you have defined a control with a name of Textcolour despite your belief to the contrary. Do an ANALYZE (from the menu bar, TOOLS >> ANALYZE >> DOCUMENTER or whatever the path is) and find all of the things listed on the form with the new controls in it. OR, check for one of the control event routines to have something declared public with that name.

The reason it worked when you moved the definition into an event routine is that technically, an event routine is merely a subroutine entry point. So a definition inside a subroutine is local to the subroutine, and scoping rules allow that particular kind of variable-name overloading.
 
OK, it is a form bound to the staff table.

There is a field in the staff table called textcolour.

But textcolour is not present on the form.

The other thing is: I never had any trouble with this form whatsoever until I added two more fields to the table, made them visible on the form, and tried to copy it into the original database.

Why now?
 

Users who are viewing this thread

Back
Top Bottom