Results 1 to 5 of 5

Thread: what is going down here?

  1. #1

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256

    what is going down here?

    alright, this maybe be lengthy to explain, but i will give it a shot. i have a form, where the user can enter how many stations are needed, and in turn, then hits the next button, and a new form loads, and depending on how many stations the user entered previously, that is how many text boxes are enabled.

    before, when the user hit the next button, i unloaded the form. but i also have back buttons. so recently, i discovered that, if you don't unload the form, and just do a form.hide, the data entered is still there. so when you hit the back button, i hide the second form.

    the problem is, if the user enters more stations, the text boxes in the next form are all the same as the first input.

    the code in the next button is the following

    VB Code:
    1. Headway = Text1
    2. Stations = Text2
    3. DailyBoardings = Text3
    4. VolumeConstant = Text4
    5. frmHeadway.Hide
    6. DoEvents
    7. Load frmTravelTimes
    8. frmTravelTimes.Show vbModal

    why doesn't it update the second form? i name stations = text2, and upon line load traveltimes has the following code
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.       'Initialize TextBoxes and Labels
    4. 10    For s = 0 To 6
    5. 20        Text1(s).Enabled = False
    6. 30        Label1(s).Enabled = False
    7. 40    Next
    8.  
    9. 50    For s = 0 To (Stations - 2)
    10. 60        Text1(s).Enabled = True
    11. 70        Label1(s).Enabled = True
    12. 80    Next
    13.  
    14. End Sub

    does it skip over the load if it is already loaded? do u need to do an unload for it to update a form. i hope i explained this well enough. there maybe a simple answer.

    thanks

    jeff

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    i wouldnt unload the form either. you can simply call the Form_Load event again though, its just like another sub-routine...
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256
    doesn't load frmTravelTimes call the Form_load event...

    also, in every form, there is a Form_load event, how do you call a form_load for a specific form?

    I know this is probably a stupid question.

    thanks,

    jeff

  4. #4
    Addicted Member
    Join Date
    Jan 2001
    Location
    MPLS
    Posts
    187
    You could just move the initialize code to the Form_Activate() instead of Form_Load(). This way weather its your 1st, 2nd, 3rd.. time showing the form the code will always run as you are expecting.

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    Originally posted by jkw119
    doesn't load frmTravelTimes call the Form_load event...

    also, in every form, there is a Form_load event, how do you call a form_load for a specific form?

    I know this is probably a stupid question.

    thanks,

    jeff
    yes the Form_Load routine will fire each time the form is loaded, but you can also call it explicitly in code.

    i.e.


    VB Code:
    1. Private Sub Command1_Click()
    2.     Form_Load
    3. End Sub

    This will not unload and reload the form etc, it will just execute the code in the Form_Load routine again
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

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