Compile error: Method or data member not found (Error 461)

gimo2003

Registered User.
Local time
Today, 13:38
Joined
Jun 27, 2011
Messages
19
Dear Friends,

I have this access error 461 which tells compile error: method or data member not found. Please help me to fix the problem with my code here:

Code:
Private Sub Command302_Click()
Command76.Enabled = False
INCIDENTREPORTSEQNO.Locked = True
[DATE].Locked = True
[CATEGORY].Locked = True
[AREA].Locked = True
[UNIT NO].Locked = True
[EQUIPMENT].Locked = True
[TIME].Locked = True
[TRIP].Locked = True
[FIRE].Locked = True
[DUMP].Locked = True
[RUPTURE].Locked = True
[EXPLOSION].Locked = True
[OTHERS 1].Locked = True
[POWER LOSS].Locked = True
[WATER LOSS].Locked = True
[PROPERTY DAMAGE].Locked = True
[PERSONAL INJURY].Locked = True
[OTHER CAUSE].Locked = True
[POWER GEN PRIOR TO INCIDENT].Locked = True
[POWER GEN AFTER THE INCIDENT].Locked = True
[WATER PROD PRIOR TO THE INCIDENT].Locked = True
[WATER PROD AFTER THE INCIDENT].Locked = True
[SE].Locked = True
[SN].Locked = True
[SBN].Locked = True
[SUS].Locked = True
[OTH].Locked = True
[NM].Locked = True
[DP].Locked = True

MsgBox ("All Data has been locked .... ")


End Sub

Private Sub Command303_Click()
 ' ask for password
                    strInput = InputBox(" Please Enter Password ", _
                                        " Restricted area ")
                    If strInput = "" Or strInput = Empty Then
                        MsgBox " Please Enter Password ", , "Required Data"
                        Exit Sub
                    End If
                    If strInput = "123" Then
                    Else
                        MsgBox (" You are not athorized ")
                        Exit Sub
                    End If
    

INCIDENTREPORTSEQNO.Locked = False
[DATE].Locked = False
[CATEGORY].Locked = False
[AREA].Locked = False
[UNIT NO].Locked = False
[EQUIPMENT].Locked = False
[TIME].Locked = False
[TRIP].Locked = False
[FIRE].Locked = False
[DUMP].Locked = False
[RUPTURE].Locked = False
[EXPLOSION].Locked = False
[OTHERS 1].Locked = False
[POWER LOSS].Locked = False
[WATER LOSS].Locked = False
[PROPERTY DAMAGE].Locked = False
[PERSONAL INJURY].Locked = False
[OTHER CAUSE].Locked = False
[POWER GEN PRIOR TO INCIDENT].Locked = False
[POWER GEN AFTER THE INCIDENT].Locked = False
[WATER PROD PRIOR TO THE INCIDENT].Locked = False
[WATER PROD AFTER THE INCIDENT].Locked = False
[SE].Locked = False
[SN].Locked = False
[SBN].Locked = False
[SUS].Locked = False
[OTH].Locked = False
[NM].Locked = False
[DP].Locked = False

Command76.Enabled = True


' all field list you want to locked

End Sub


To explain further what's the problem on these codes: the field names:

[SE]
[SN]
[SBN]
[SUS]
[OTH]
[NM]
[DP]

are additional field names that I placed on the table, which I added also on my queries, reports, and forms. I have put two buttons in the form: the enable button and the lock button. The problem lies whenever I opened the form, only the old field names on my table were locked and those added new field names are not locked, even going through the codes that added field names were added in the code as shown above. What seems to be the problem? Thank you in advance.
 
Last edited by a moderator:
you need the control names on the form, not the names of the bound data for your statements.

when you add controls after the original design, they are not necessarily named the same.

I would check that.
 
Thank you gemma-the-husky for a quick reply. All the names indicated in the code are included in the form and on the table and even in the queries where my form's control source is connected. Maybe you are right that when I add the new names on the table, I have overwritten old names on the original table which created a gap and would not consider the added names in the code. Originally, my database was created in access 97 which later uploaded to run on access 2000, is this a factor to consider why some codes are not running properly. Thanks again, hoping you could check what I am missing here.:)
 
Thank you bob fitz for your quick reply. I will check where the error lies.
 
I personally would add a tag to all the controls you want to lock / unlock and then loop through them.
The tag value is exposed under "Other" properties. If you set it to EditTag or similar then add the following code (this also sets the back colour, but as you can see it's much simpler to code);

Code:
Dim ctl As Control

    For Each ctl In Me.Controls
        If ctl.Tag = "EditTag" Then
            ctl.Locked = False
            ctl.BackColor = 16777215
        End If
    Next ctl
 
put a breakpoint at the first assignment, and then F8 until it breaks, if you can't find it by inspection.

are you absolutely sure, that

[SE] is both the name of the field in the table, and the name of the control on this form, and is also the control source of the control on the form?
 
To: Gemma-the-husky,

Hi Gemma-the-husky, I tried to put a breakpoint on the following disputed field names: [SE], [SN], [SBN], [SUS], [OTH], [NM], and [DP] and this is what I've got after F8: Compile error: type mismatch highlighting the code (hlib) from FreeLibrary(hLib):


Public Function MouseWheelON() As Boolean
MouseWheelON = StartMouseWheel(Application.hWndAccessApp)
If hLib <> 0 Then
hLib = FreeLibrary(hLib)

End If
End Function

And I make it sure also that [SE] and the rest of the newbies' field names were declared on the table, queries, forms, and in the reports.

Thanks for the visit.
 
Hi Minty,

Thanks for your visit. I tried to tag controls but still unable to lock those fields mentioned.:)
 
What happens - do you get an error message? If so add some debugging code;
Code:
Dim ctl As Control

    For Each ctl In Me.Controls
       
        If ctl.Tag = "EditTag" Then
      [COLOR="Green"][COLOR="Red"]      Debug.Print ctl.Name[/COLOR][/COLOR]
            ctl.Locked = False
            ctl.BackColor = 16777215 
                    End If
    Next ctl

This will show you which control is causing you the problem. Press Ctrl-G to get the immediate window up.
 
@Gimo:
Sounds like you have a missing .dll file. Perhaps you tried to customize your mouse's behavior in some way?

See this link for some additional info.
 
To: mjdemaris,

Before I was receiving error: missing .dll file, so what I did to eliminate this error message was to get rid of the code where the MouseWheel is located and it did the trick, every time I opened the program, the error message is gone. Thanks for your kind visit.:)
 
Minty:

Where do I actually put the code that you suggested? Is it in the property sheet of the form or on the property sheet of the problematic field names:
[SE]
[SN]
[SBN]
[SUS]
[OTH]
[NM]
[DP]

that I would like to put a lock every time I opened the form. Where do I exactly put this code that you shared? Thanks again for your visit.:)
 
Lock all the fields you need locked by default in the design view on the form. Add the code to your correct password entry code. So the flow is
  • Form opened - All fields locked by design.
  • Correct Password entered
  • Loop round the controls temporarily unlocking them.
  • Enable any other relevant buttons at the same time.
Close the form - next time it's opened you are back where you started.
 
@gimo:
If you put a stop in your loop:
Code:
For Each ctrl ...

Stop
Next ctrl
It will loop once, then stop. Then, use the F5 key to loop again until a control throws the error, or user F8 to step through the code one line at a time.

Just to make sure, these 'newbie fields' are actual controls on the form, yes? If not, then I always use a simple naming convention. For example a text box: txtFirstName; for a label: lblFirstName.

Also, watch out for keywords like DATE, NAME, etc.
 
mjdemaris,

Thanks for your suggestions. Only these field names:

[SE]
[SN]
[SBN]
[SUS]
[OTH]
[NM]
[DP]

which I added along with other field names are not being locked upon the open form, they are already registered in the table, forms, queries and reports. I don't know why only these field names are not being locked upon the opening form. Thanks again for the visit.
 
Minty,

I am still figuring out the problem, but still I could not lock these field names in the form:

[SE]
[SN]
[SBN]
[SUS]
[OTH]
[NM]
[DP]

These field names were already registered in the table, forms, queries, and in the report. Thanks for the visit.
 
You don't lock fields, you lock controls, and I suspect this might be where your problem lies. The code I posted loops through any control you set the tag control on.

Check what the control is called (it's Name property), and look to see if it appears when the debug.print outputs the control names.
 
Why don't you share a copy of your database, removing any sensitive items. I think we need to see what is happening to understand what you are telling us.
 
mjdemaris,

Hi I am back again, sorry late reply to you. In google, I have this program of Allen Browne about locking bound controls, it did the trick of locking the forms upon the opening of form, only the problem was it also included locking my subform in TabCtl. Still looking to fix this problem. Thanks a lot for your visit.
 

Users who are viewing this thread

Back
Top Bottom