Results 1 to 2 of 2

Thread: Combine 2 subs
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2018
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Combine 2 subs

    Hi guys, i would like to combine the codes below so that you can only double click when you are logged in;

    Code:
    Private Sub cmdLogin_Click()
    If txtPassword.Value = "1" And txtUsername.Text = "ROH1" Then
    With AdvancedInformation
    .lblInformation.Visible = False
    .cmdLogin.Enabled = False
    .cmdCancel.Enabled = True
    .cmdCancel.SetFocus
    .lblAdministrator.Caption = "Hello administrator," & vbNewLine & "Double-click the values that you would like to change." & vbNewLine & "Changes are automatically saved."
        
    'Page(s)
    'Show border and change it's colour to blue
        .lblPagesR.BorderStyle = fmBorderStyleSingle
        .lblPagesR.BorderColor = RGB(0, 0, 255)
        .lblInputfieldR.BorderStyle = fmBorderStyleSingle
        .lblInputfieldR.BorderColor = RGB(0, 0, 255)
        .lblChecksR.BorderStyle = fmBorderStyleSingle
        .lblChecksR.BorderColor = RGB(0, 0, 255)
        .lblDoubleCheckR.BorderStyle = fmBorderStyleSingle
        .lblDoubleCheckR.BorderColor = RGB(0, 0, 255)
        .lblRMcodesR.BorderStyle = fmBorderStyleSingle
        .lblRMcodesR.BorderColor = RGB(0, 0, 255)
        .lblBatchnumbersR.BorderStyle = fmBorderStyleSingle
        .lblBatchnumbersR.BorderColor = RGB(0, 0, 255)
        .lblRoomnumbersR.BorderStyle = fmBorderStyleSingle
        .lblRoomnumbersR.BorderColor = RGB(0, 0, 255)
    'Weighing form(s)
    'Show border and change it's colour to blue
        .lblWeighingformsR.BorderStyle = fmBorderStyleSingle
        .lblWeighingformsR.BorderColor = RGB(0, 0, 255)
        .lblInputFields1R.BorderStyle = fmBorderStyleSingle
        .lblInputFields1R.BorderColor = RGB(0, 0, 255)
        .lblRoomnumbers1R.BorderStyle = fmBorderStyleSingle
        .lblRoomnumbers1R.BorderColor = RGB(0, 0, 255)
        .lblDatesR.BorderStyle = fmBorderStyleSingle
        .lblDatesR.BorderColor = RGB(0, 0, 255)
        .lblENScodesR.BorderStyle = fmBorderStyleSingle
        .lblENScodesR.BorderColor = RGB(0, 0, 255)
        .lblSignsR.BorderStyle = fmBorderStyleSingle
        .lblSignsR.BorderColor = RGB(0, 0, 255)
    End With
    Unload Me
    Else
    If MsgBox("The username and/or password is incorrect. Please try again.", vbYesNo) = vbNo Then
    Unload Me
        Else
        txtUsername.Text = ""
        txtPassword.Text = ""
        txtUsername.SetFocus
        End If
    End If
    End Sub
    Code:
    Private Sub lblPagesR_DblClick(ByVal Cancel As MSForms.ReturnBoolean)Dim stCaption As String
    
    
        stCaption = InputBox("Add new caption", , lblPagesR)
            If stCaption = vbNullString Then Exit Sub
            lblPagesR = stCaption
    End Sub
    How do i do that?

    Thanks in advance

  2. #2
    Board Regular
    Join Date
    Mar 2015
    Posts
    3,908
    Post Thanks / Like
    Mentioned
    72 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Combine 2 subs

    Untested
    - but this method works with Worksheet_BeforeDoubleClick


    Try this

    at TOP of a STANDARD module declare a public variable (must precede any procedures)
    Code:
    Public DblClick As Boolean

    In cmdLogin_Click ... insert this as 1st line
    Code:
    DblClick = False
    AND immediately below this line ...
    Code:
    txtUsername.SetFocus
    .. insert this line
    Code:
    DblClick = True

    In lblPagesR_DblClick ... insert this as 1st line
    Code:
    If DblClick = False Then Cancel = True
    Last edited by Yongle; Jun 28th, 2019 at 08:40 AM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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