Compile error: Method or data member not found

Michael515

Board Regular
Joined
Jul 10, 2014
Messages
136
Hi,

I am trying to create a simple login button and have cross referenced my code across a couple web pages and it all seems to check yet I still get a Compile error: method or data member not found. Any thoughts?

Code:
Private Sub LoginButton_Click()
If Me.Username.Value = "Admin" Then
    If Me.Password.Value = "1234" Then
        LoginFlag = True
        Unload Me
        Exit Sub
    End If
End If
MsgBox "Sorry, you are not an authorized user"
End Sub
 
Private Sub Worksheet_Activate()
If LoginFlag = False Then
    Worksheet(1).Activate
    Login.Show
End If
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Where in the posted code do you get the error?

Also, you mention web pages but I'm not seeing any references to them in the posted code, is that in the rest?
 
Upvote 0
When I open up the debugger it highlights the Private Sub LoginButton_Click() specifically highlighting the .Value of the If Me.Username line.


When I mentioned web pages I was talking to that I looked up how to make a login button across multiple forums and the code seemed to be consistent across all of them.
 
Upvote 0
How are you running/triggering this code?
 
Upvote 0
There is a sheet in the workbook called "Login Details," when you click into that sheet the login window pops up. The login is supposed to act similar to a workbook protection, just more formalized. What we, myself and co-worker, want to do is have the login pop up when you enter the workbook, if your login id and password match one of the allowables, you can make changes, if not, you can only view. We thought that the login button would suffice. Note that the code I shared is the code behind the login button, not necessarily tied to any sheet.
 
Upvote 0
are two objects below shown in RED the names of TextBoxes on your userform?

Rich (BB code):
If Me.UserName.Value = "Admin" Then
    If Me.Password.Value = "1234" Then
        LoginFlag = True
        Unload Me
        Exit Sub
    End If
End If

Dave
 
Last edited:
Upvote 0
FYI, you also have an error in the Activate event which should read:

Rich (BB code):
Private Sub Worksheet_Activate()
If LoginFlag = False Then
    Worksheets(1).Activate
    Login.Show
End If
End Sub
 
Upvote 0
Are you referring to the line item in the properties of the Username field as in (Name)? Or are you referring to what we actually typed into the username field area?
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,239
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top