Results 1 to 9 of 9

Thread: Form_Load Event issue

  1. #1

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Form_Load Event issue

    I have a form that has a lot of code in the Form_Load event. The problem is my form only shows after the code runs. How could I have the Form show at a certain stage in my code.

    I tried the DoEvents command...

    Is there even a way I can do this or do I need to setup something else?

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Form_Load Event issue

    VB Code:
    1. Show
    or
    VB Code:
    1. Me.Show
    and put that when you want it to show.

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Form_Load Event issue

    Quote Originally Posted by Avatarp
    I have a form that has a lot of code in the Form_Load event. The problem is my form only shows after the code runs. How could I have the Form show at a certain stage in my code.
    I tried the DoEvents command...
    Is there even a way I can do this or do I need to setup something else?
    You can always..
    VB Code:
    1. Private Sub Form_Load()
    2.     Me.Show
    3.     'Your Form_Load code..
    4. End Sub

  4. #4

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Re: Form_Load Event issue

    i did that but none of my code runs

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim Activation_Status_String As String
    3.     Me.Show 1
    4.     chkActive.Value = IIf(GetSetting("IntelliSchedule", "Weekend_Scheduling_Form_Controls", "ShowActiveEmps") = "", 1, GetSetting("IntelliSchedule", "Employees_Form_Controls", "ShowActiveEmps"))
    5.     chkShowLeave.Value = IIf(GetSetting("IntelliSchedule", "Weekend_Scheduling_Form_Controls", "ShowLeaveEmps") = "", 1, GetSetting("IntelliSchedule", "Employees_Form_Controls", "ShowLeaveEmps"))
    6.     chkShowInactive.Value = IIf(GetSetting("IntelliSchedule", "Weekend_Scheduling_Form_Controls", "ShowInactiveEmps") = "", 1, GetSetting("IntelliSchedule", "Employees_Form_Controls", "ShowInactiveEmps"))
    7.  
    8.     DoEvents
    9.    
    10.     DTPickerWeekend(0).Value = CDate("01/01/" & Year(Now))
    11.     DTPickerWeekend(1).Value = CDate("12/31/" & Year(Now))
    12.     Call Populate_Department_Combobox(comboboxTeamView)
    13.     comboboxTeamView.ListIndex = 0
    14. '    Activation_Status_String = Create_Activation_Status_String(chkActive, chkShowLeave, chkShowInactive)
    15. '    Call Populate_Employee_List(comboboxTeamView.Text, lstVwEmployees, Activation_Status_String)
    16.  
    17.     Call Set_Employee_Weekend_Grid
    18.     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    19.     '   Auto Populate Employee Grid
    20.     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    21.     Call Populate_Employee_Weekend_Grid_Names(comboboxTeamView.Text)
    22.     Call Populate_Employee_Weekend_Grid_Days(comboboxTeamView.Text, DTPickerWeekend(0).Value, DTPickerWeekend(1).Value)
    23.  
    24. End Sub

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Form_Load Event issue

    Maybe becuase you are showing it Modally, if you do it modally the code after show 1 won't be executed until the Form closes

  6. #6
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Form_Load Event issue

    Use only
    VB Code:
    1. Me.Show
    so it doesn't show as modal.

  7. #7

    Thread Starter
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Re: Form_Load Event issue

    hmm so no way to do this if it is modal?

  8. #8
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Form_Load Event issue

    If another form is opening it then use
    VB Code:
    1. Form1.Show VbModal, Me

  9. #9
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Form_Load Event issue

    Yes, put that code in Form_Activate() event, so it will be executed after your Form is already visible.
    And remove the Me.Show from there, use Form.Show 1 in the Form that call this one, as Andrew G said.
    Last edited by jcis; Feb 25th, 2006 at 11:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width