Combine 2 subs

Bandito1

Board Regular
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
 

Yongle

Well-known Member
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:

Some videos you may like

This Week's Hot Topics

Top