Results 1 to 2 of 2

Constant code interruption...

Threaded View

  1. #1
    Registered User
    Join Date
    08-27-2009
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2007
    Posts
    45

    Constant code interruption...

    I have created a UserForm that allows people to log-in to my worksheet -using stored information in A:A(username) and B:B (password).

    On the same sheet, I have a cell in which I would like the UserForm to paste the "Username" entry of the form into Cell J2 (this will be used to check the current user logged in). It's really frustrating as I have found the route cause, and tried many different scenarios, to no avail.

    My full code is below, the highlighted range (red) seems to be the thing causing all of these problems. I can run the code once (on occasion twice) before it takes me to the VBE and highlights the "Private Sub LogInButton_Click() UserLogIn.Show part, with a message saying the code had been interrupted.

    as soon as you remove it from the code it works perfectly. Is there a way around this?

    UserForm Code
     Private Sub CancelButton_Click()
    
    Unload Me
    
    End Sub
    
    Private Sub ClearButton_Click() Call UserForm_Initialize End Sub
    Private Sub OKButton_Click() Sheets("LogIn").Activate On Error GoTo user_not_Found If TextPassword.Value = Range("B" & Application.WorksheetFunction.Match(TextUsername.Value, Range("A:A"), 0)) Then MsgBox "Welcome back, " & TextUsername.Value & ".", vbOKOnly, "Success" Unload Me Range("J2").Value = TextUsername.Value Else GoTo user_not_Found End If Exit Sub user_not_Found: MsgBox "Incorrect details given", vbExclamation, "Incorrect" End Sub
    Private Sub UserForm_Initialize() 'Empty Username Text TextUsername.Value = "" 'Empty Password Text TextPassword.Value = "" ' 'Set Focus on NameTextBox TextUsername.SetFocus End Sub
    Sheet Code
    Private Sub LogInButton_Click()
    
    UserLogIn.Show
    
    End Sub
    
    Private Sub RegisterButton_Click() UserRegister.Show End Sub
    Last edited by RayJay01; 05-22-2013 at 05:21 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1