从另一个用户窗体调用用户窗体时显示的正在加载光标

时间:2019-02-28 05:07:00

标签: excel vba

我有一个userform1,它调用另一个userform2来接受一些数据。成功卸载用户窗体2后,控件又回到用户窗体1。但是,我注意到蓝色的加载光标(旋转一个)。那时,在用户窗体1中什么都没有起作用,但是一旦我在工作表中的某个位置单击,它就正常了。

由于我的表格仍在工作,这似乎不是一个大问题。但这让我很烦恼,以至于我在关闭时像设置任何属性一样没有正确执行任何操作。

更多信息-用户窗体2和3可以访问用户窗体2。当用户窗体1调用用户窗体2和agentupdateflag时,我提到的加载光标的情况正在发生,当用户窗体3调用屏幕时为true < / p>

调用用户窗体2的代码

Private Sub agentname_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    agentupdateflag = False
    On Error Resume Next
    userform2.Show
End Sub

用户窗体2初始化代码

Private Sub UserForm_Initialize()

agentstatus.AddItem ("Active")
agentstatus.AddItem ("Inactive")

If agentupdateflag = True Then
    Userform2.Agentid.Caption = Userform3.agentlist.List(Updateval, 0)
    Userform2.Agentname.value = Userform3.agentlist.List(Updateval, 1)
    Userform2.agentaddr.value = Userform3.agentlist.List(Updateval, 2)
    Userform2.agentcontact.value = Userform3.agentlist.List(Updateval, 3)
    Userform2.agentstatus.value = Userform3.agentlist.List(Updateval, 5)
    Userform2.agentidproof.value = Userform3.agentlist.List(Updateval, 6)
    Userform2.Caption = "Update Agent Details"
    addagent.Caption = "Update Agent"
    agentstatus.Locked = False
Else
    agentstatus.value = "Active"
    agentstatus.Locked = True
End If

End Sub

需要处理的用户表单2终止代码

Private Sub UserForm_Terminate()

If agentupdateflag = False Then
    Application.EnableEvents = False
On Error GoTo err1
    Userform1.agentname.Clear
    j = 2
    Set ShDest = ThisWorkbook.Worksheets("Agent_info_Temp")
    Final_lastrow = ShDest.Cells(ShDest.Rows.Count, "B").End(xlUp).Row
    Final_lastcol = ShDest.Cells(1, ShDest.Columns.Count).End(xlToLeft).Column
    ShDest.Activate

    With Userform1.agentname
        Do While j <= Final_lastrow
            If Trim(ShDest.Range("a" & j).value) <> "" Then
            .AddItem (ShDest.Range("a" & j).value & " - " & ShDest.Range("B" & j).value)
            End If
            j = j + 1
        Loop
    End With
    Userform1.agentname.ListIndex = Userform1.agentname.ListCount - 1
    Application.EnableEvents = True
    'Unload Me
Else
    'Unload Me
    Call Userform3.searchagent_Click
End If
'Unload Me

err1:
If Err.Number <> 0 Then
    Msg = "Error # " & Str(Err.Number) & " was generated by " _
            & Err.Source & vbNewLine & vbNewLine & Err.Description & vbNewLine & vbNewLine & "Contact System Admin."
    MsgBox Msg, vbOKOnly + vbCritical, "Critical System Error Encountered !", Err.HelpFile, Err.HelpContext
End If
Exit Sub

End Sub

0 个答案:

没有答案