Combine 2 subs

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
239
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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