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
 
When you type Me. in the code, do you see Username in the list of available Intellisense items after typing the full stop?
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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?

Is the "UserName Field" a TextBox in your UserForm Named "UserName"? same with "Password"

Dave
 
Upvote 0
When I typed the Me., username did pop up, but after typing username, value did not pop up, so I'm guessing that is were the problem lies.
 
Upvote 0
I figured it out y'all. The reason the .value field was not auto-populating was because the Username box was referring to the label username and not the textbox where you actually typed in the username. My code should have read

Code:
Private Sub LoginButton_Click()
IF Me.Textbox1.Value = "Admin"

Instead of

Code:
Private Sub LoginButton_Click()
IF Me.Username.Value = "Admin"

Thanks for the help guys. The constant flow of ideas kept me thinking and eventually I figured out why the .value was appearing. If it wasn't for your questions, I would not have thought critically enough and stumbled upon my mistake! Thank you all for your time and help!
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,731
Members
449,093
Latest member
Mnur

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