Combine 2 subs

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
85
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
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,310
Office Version
365
Platform
Windows
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:

Watch MrExcel Video

Forum statistics

Threads
1,101,949
Messages
5,483,840
Members
407,415
Latest member
Anton1999

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top