简体   繁体   English

命令按钮代码停止工作

[英]Command Button Code stopped working

I was using this user form code yesterday and everything worked fine. 昨天我正在使用此用户表单代码,并且一切正常。 Today, nothing is working. 今天,什么都没用。 When my command button "Complete" is clicked, the code should verify that the user form is complete (Complete_Enter()) and then transfer the information from the userform to my worksheet. 当单击我的命令按钮“完成”时,代码应验证用户表单是否完整(Complete_Enter()),然后将信息从用户表单传输到我的工作表中。 This all worked perfectly yesterday and today it does not. 昨天所有这些都运行良好,今天却没有。 Instead when I click complete, VBA only runs the first line under the Complete_Enter() sub. 相反,当我单击完成时,VBA仅在Complete_Enter()子下面运行第一行。 Here is the code: 这是代码:

Private Sub ConnectorCoverProductionForm_Initialize()

'Empty Serial_NumberTextBox
Serial_Number.Value = ""
Serial_Number.SetFocus

'Empty Order_NumberTextBox
Order_Number.Value = ""

'Empty DateTextBox
TextBox1.Value = ""

Inspector.Clear
Assembler.Clear
Process_Code.Clear

'Uncheck OptionButton
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
OptionButton4.Value = False
OptionButton5.Value = False
OptionButton6.Value = False
OptionButton21.Value = False
OptionButton12.Value = False
OptionButton13.Value = False
OptionButton14.Value = False
OptionButton15.Value = False
OptionButton16.Value = False


End Sub
Private Sub Assembler_DropButtonClick()
Assembler.List = Array("Trung", "Jesus", "Khoi", "Josie", "Omi")
End Sub
Private Sub ClearALL_Click()

Call ConnectorCoverProductionForm_Initialize

End Sub

Private Sub CommandButton1_Click()
Shell ("Explorer \\PC148\Assembly Group\Traveler 
End Sub
Private Sub CommandButton2_Click()
Shell ("Explorer \\PC148\Assembly Group\Traveler               
End Sub

Private Sub CommandButton3_Click()
Shell ("Explorer \\PC148\Assembly Group\Traveler Templates\Videos\Edited\Mag 
End Sub

Private Sub CommandButton4_Click()
Shell ("Explorer \\PC148\Assembly Group\Traveler Templates\Videos\Edited\Mag 
End Sub

Private Sub Complete_Click()

Dim emptyRow As Long

Sheet1.Activate

emptyRow = WorksheetFunction.CountA(Range("C:C")) + 1

Cells(emptyRow, 3).Value = Serial_Number.Value
Cells(emptyRow, 4).Value = Order_Number.Value
Cells(emptyRow, 5).Value = TextBox1.Value
Cells(emptyRow, 6).Value = Revision.Value
Cells(emptyRow, 7).Value = Inspector.Value
Cells(emptyRow, 8).Value = Assembler.Value
Cells(emptyRow, 9).Value = Process_Code.Value
If OptionButton1.Value = True Then Cells(emptyRow, 10).Value =         OptionButton1.Caption
If OptionButton21.Value = True Then Cells(emptyRow, 10).Value = OptionButton21.Caption
If OptionButton2.Value = True Then Cells(emptyRow, 11).Value = OptionButton2.Caption
If OptionButton12.Value = True Then Cells(emptyRow, 11).Value = OptionButton12.Caption
If OptionButton3.Value = True Then Cells(emptyRow, 12).Value = OptionButton3.Caption
If OptionButton13.Value = True Then Cells(emptyRow, 12).Value = OptionButton13.Caption
If OptionButton4.Value = True Then Cells(emptyRow, 13).Value = OptionButton4.Caption
If OptionButton14.Value = True Then Cells(emptyRow, 13).Value = OptionButton14.Caption
If OptionButton5.Value = True Then Cells(emptyRow, 14).Value = OptionButton5.Caption
If OptionButton15.Value = True Then Cells(emptyRow, 14).Value = OptionButton15.Caption
If OptionButton6.Value = True Then Cells(emptyRow, 15).Value = OptionButton6.Caption
If OptionButton16.Value = True Then Cells(emptyRow, 15).Value = OptionButton16.Caption

End Sub

Private Sub Complete_Enter()

If Serial_Number.Value = "" Then MsgBox "Fill in Serial Number"
Exit Sub

If Order_Number.Value = "" Then MsgBox "Fill in Order Number"
Exit Sub

If TextBox1.Value = "" Then MsgBox "Fill in Date"
Exit Sub
If Revision.Value = "" Then MsgBox "Select the correct Revision"
Exit Sub
If Inspector.Value = "" Then MsgBox "Who was the inspector? If it was you,select 'SELF'"
Exit Sub
If Assembler.Value = "" Then MsgBox "Select Your Name as the Assembler"
Exit Sub
If Process_Code.Value = "" Then MsgBox "Select the correct Process Code"
Exit Sub
If OptionButton1.Value = False And OptionButton21.Value = False Then MsgBox "What is the Status of Step 1"
Exit Sub
If OptionButton2.Value = False And OptionButton12.Value = False Then MsgBox "What is the Status of Step 2"
Exit Sub
If OptionButton3.Value = False And OptionButton13.Value = False Then MsgBox "What is the Status of Step 3"
Exit Sub
If OptionButton4.Value = False And OptionButton14.Value = False Then MsgBox "What is the Status of Step 4"
Exit Sub
If OptionButton5.Value = False And OptionButton15.Value = False Then MsgBox "What is the Status of Step 5"
Exit Sub
If OptionButton6.Value = False And OptionButton16.Value = False Then MsgBox "What is the Status of Step 6"
Exit Sub


End Sub

Private Sub Inspector_DropButtonClick()
Inspector.List = Array("Tom", "Tre", "Omi", "Self")
End Sub

Private Sub Process_Code_DropButtonClick()
Process_Code.List = [index(12*(row(1:12)-1),)]
End Sub
Private Sub Revision_DropButtonClick()
Revision.List = [index(char(64+row(1:26)),)]
End Sub

I expect your routine should be modified like so: 我希望您的例程应该像这样修改:

Private Sub Complete_Enter()
    If Serial_Number.Value = "" Then
        MsgBox "Fill in Serial Number"
    ElseIf Order_Number.Value = "" Then
        MsgBox "Fill in Order Number"
    ElseIf TextBox1.Value = "" Then
        MsgBox "Fill in Date"
    ElseIf Revision.Value = "" Then
        MsgBox "Select the correct Revision"
    ElseIf Inspector.Value = "" Then
        MsgBox "Who was the inspector? If it was you,select 'SELF'"
    ElseIf Assembler.Value = "" Then
        MsgBox "Select Your Name as the Assembler"
    ElseIf Process_Code.Value = "" Then
        MsgBox "Select the correct Process Code"
    ElseIf OptionButton1.Value = False And OptionButton21.Value = False Then
        MsgBox "What is the Status of Step 1"
    ElseIf OptionButton2.Value = False And OptionButton12.Value = False Then
        MsgBox "What is the Status of Step 2"
    ElseIf OptionButton3.Value = False And OptionButton13.Value = False Then
        MsgBox "What is the Status of Step 3"
    ElseIf OptionButton4.Value = False And OptionButton14.Value = False Then
        MsgBox "What is the Status of Step 4"
    ElseIf OptionButton5.Value = False And OptionButton15.Value = False Then
        MsgBox "What is the Status of Step 5"
    ElseIf OptionButton6.Value = False And OptionButton16.Value = False Then
        MsgBox "What is the Status of Step 6"
    End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM