Unable to get the TextBoxes Property when login !

MAlhash

New Member
Joined
Mar 26, 2023
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have created an excel sheet which have two textboxes "username" and "password" as a login system. I did not use the visual basic form to design. I have only insert 2 textboxes on the sheet and a picture as a login. if i click the picture it should login. its checking the password and the usernames from a table.

I have completed the code. however, it is giving me an error when compiling it.

one note, my textbox is an activex control

VBA Code:
Sub PLSLOGIN_CLICK()

    Dim wsAdmin As Worksheet
    Dim inputusername As String
    Dim inputPassword As String
    Dim userLookupResult As Variant
    Dim passwordLookupResult As Variant

    Set wsAdmin = Worksheets("ADMIN")
   
    inputusername = Worksheets("LOGIN").TextBoxes("txtUsername").Value   /////// the erorr is"Unable to get the Textboxes property of the worksheet class"
    inputPassword = Worksheets("LOGIN").TextBoxes("txtPassword").Value

    userLookupResult = Application.VLookup(inputusername, wsAdmin.ListObjects("tblAcess").DataBodyRange, 1, False)
    passwordLookupResult = Application.VLookup(inputusername, wsAdmin.ListObjects("tblAcess").DataBodyRange, 2, False)
   
    If Not IsError(userLookupResult) And Not IsError(passwordLookupResult) Then
   
        If passwordLookupResult = inputPassword Then
       
        Call Login
             
        Else
       
        'Bad Login
            MsgBox "Login Failed!"
       
        End If
       
   
    Else
            'Bad Login
            MsgBox "Login Failed!"
   
    End If

End Sub


Thank you!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
VBA Code:
     ' try replacing
    inputusername = Worksheets("LOGIN").TextBoxes("txtUsername").Value   /////// the erorr is"Unable to get the Textboxes property of the worksheet class"
    inputPassword = Worksheets("LOGIN").TextBoxes("txtPassword").Value
    ' with'
     inputusername = Worksheets("LOGIN").OLEObjects("txtUsername").Object.Text
    inputPassword = Worksheets("LOGIN").OLEObjects("txtPassword").Object.Text
 
Upvote 0
Solution

Forum statistics

Threads
1,215,073
Messages
6,122,974
Members
449,095
Latest member
Mr Hughes

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