multiple checks before an action

Chief

Registered User.
Local time
Today, 14:58
Joined
Feb 22, 2012
Messages
156
Hello,
I have some code which works perfectly for what I want. (This is it below)

Code:
Private Sub LblPShop_Complete_Click()
        If ChkPShop_Complete = True Then
            Dim iResponse As String
            'Ask if they are sure they want to change it and store their response in iResponse.
            iResponse = MsgBox("Do you wish to change the status of this job for Paint Shop Complete?  ", vbYesNo + vbExclamation + vbApplicationModal + vbDefaultButton1, "Change Manufacturing.")
            
            Select Case iResponse
                Case vbYes: 'They answered Yes
                    Dim strPassword As String
                    strPassword = InputBox("Please enter the admin password", "Change Status of Manufacturing") 'get password with input box
                    If strPassword = "Haus" Then
                        ChkPShop_Complete = False 'sets the check box to false.
                        Form_JobDetailF.TxtPShop_Complete = ""
                        LblPShop_Complete.Caption = ""
                    Else
                        Call MsgBox("The password you entered is incorrect.  ", vbOKOnly + vbCritical + vbApplicationModal + vbDefaultButton1, "Incorrect Password")
                    End If
                Case vbNo: 'If they select no to changing it it does nothing.
        
            End Select
            
        Else ' it is false
            ChkPShop_Complete = True
            Form_JobDetailF.TxtPShop_Complete = Date
            LblPShop_Complete.Caption = Chr(252)
        End If

End Sub

However on some items I need to implement further checks. The way I have written it isn't clean and not doing exactly what I want.
It sets the focus, changes the colors etc., however not giving me the message box, and when I make the check true, it doesnt then go on to check it off.
I will have a few checks to look at, not just this one. (Code I Have is)
Code:
Private Sub LblMShop_Complete_Click()
        If ChkMShop_Complete = True Then
            Dim iResponse As String
            'Ask if they are sure they want to change it and store their response in iResponse.
            iResponse = MsgBox("Do you wish to change the status of this job for Machine Shop Complete?  ", vbYesNo + vbExclamation + vbApplicationModal + vbDefaultButton1, "Change Manufacturing.")
            
            Select Case iResponse
                Case vbYes: 'They answered Yes
                    Dim strPassword As String
                    strPassword = InputBox("Please enter the admin password", "Change Status of Machine Shop") 'get password with input box
                    If strPassword = "Haus" Then
                        ChkMShop_Complete = False 'sets the check box to false.
                        Form_JobDetailF.TxtMShop_Complete = ""
                        LblMShop_Complete.Caption = ""
                    Else
                        Call MsgBox("The password you entered is incorrect.  ", vbOKOnly + vbCritical + vbApplicationModal + vbDefaultButton1, "Incorrect Password")
                    End If
                Case vbNo: 'If they select no to changing it it does nothing.
        
            End Select
            
        Else ' it is false
            'check bid
            Dim txtmessage As String
            txtmessage = ""
                If ChkBIDs = True Then
                    If Len(Nz(Me.TxtHingeDrill)) = 0 Then
                        txtmessage = "Hinge Drill is not complete for bought in doors." & vbCrLf & txtmessage
                        Me.TxtHingeDrill.BackColor = vbRed
                        Me.TxtHingeDrill.ForeColor = vbWhite
                        Me.TxtHingeDrill.SetFocus
                    Else
                        Me.TxtHingeDrill.BackColor = vbWhite
                        Me.TxtHingeDrill.ForeColor = vbBlack
                End If
        Else
            ChkMShop_Complete = True
            Form_JobDetailF.TxtMShop_Complete = Date
            LblMShop_Complete.Caption = Chr(252)
        End If
    End If
End Sub

1635466037071.png
 
Just curious, have you tried stepping through the code to see what it's actually doing? You might be able to see if it's skipping any steps.
 
Just curious, have you tried stepping through the code to see what it's actually doing? You might be able to see if it's skipping any steps.
Stepping thru, txtmessage is saying 0 instead of the message
then skips over the check complete value at the end.
if hingedrill is complete, the function stops working all together.
 
you don't have MsgBox to display the message.
also add code to the Change event of TxtHingeDrill.
If there is value, check the adjacent checkbox.
 
you don't have MsgBox to display the message.
also add code to the Change event of TxtHingeDrill.
If there is value, check the adjacent checkbox.
yes, bugga.. ok getting message box now, thank you..

but not getting any action on the complete now equals true if txthinge is not 0

Have I written this correctly? with the else then the other ifs, with another else?
Doesn't look right or clean, especially as I will be adding more checks.

thanks
 
you need a Code on the Change or BeforeUpdate or AfterUpdate of the txtHinge.
check the length again and remove the red color if there is date and check the adjacent checkbox.
 

Users who are viewing this thread

Back
Top Bottom