Results 1 to 9 of 9

Thread: Change event with form load

  1. #1

    Thread Starter
    Addicted Member Beengie's Avatar
    Join Date
    Nov 2003
    Location
    Central Valley, CA
    Posts
    243

    Change event with form load

    I was wondering how I could get a form to load and populate the textboxes without triggering the "Change" event on the textbox.
    Once the form is loaded, then I wanted to use the "Change" event.
    BeengieHappy.Vaue = (SharksScore > OpponentsScore)

    Go Sharks!

  2. #2
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Change event with form load

    if you cant hardcode the textbox value you could have a private boolean to say if the form is loaded or not.
    VB Code:
    1. Option Explicit
    2. Private loaded As Boolean
    3.  
    4. '------------------------
    5. Private Sub Form_Load()
    6.  Text1.Text = "some text"
    7.  loaded = True
    8. End Sub
    9.  
    10. '------------------------
    11. Private Sub Text1_Change()
    12.  If loaded = True Then
    13.   'your code
    14.  End If
    15. End Sub

    casey.

  3. #3
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: Change event with form load

    You could create a boolean and turn the boolean to true once the textboxes are populated. Then on each textbox change event put everything inside: 'If boolean = True then', so that they are only triggered when the boolean is true, obviously. So is that what you are looking for?

  4. #4
    Addicted Member
    Join Date
    May 2005
    Posts
    168

    Re: Change event with form load

    Hi,

    You can try this.

    VB Code:
    1. Option Explicit
    2. Dim Loading As Boolean
    3.  
    4. Private Sub Form_Load()
    5.     Loading = True
    6.     Text1.Text = "loading"
    7.     Loading = False
    8. End Sub
    9.  
    10. Private Sub Text1_Change()
    11.     If Loading Then Exit Sub Else MsgBox "Change event fired"
    12. End Sub

    Have a good one!
    BK

  5. #5
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: Change event with form load

    I wonder who removed my last post...sorry if it offended anyone, was just joking =P.

  6. #6

    Thread Starter
    Addicted Member Beengie's Avatar
    Join Date
    Nov 2003
    Location
    Central Valley, CA
    Posts
    243

    Re: Change event with form load

    It didn't work when I tried it vbasicgirl's way. I haven't tried the others yet.
    VB Code:
    1. ' ****************
    2. ' This is in frmMaterials
    3. ' ****************
    4. Private Sub flxgrdMaterials_DblClick()
    5. frmMatDialog.PopMatEdit (flxgrdMaterials.TextMatrix(flxgrdMaterials.RowSel, 0))
    6. frmMatDialog.Show vbModal
    7. End Sub
    8.  
    9. ' ****************
    10. ' this is in frmMatDialog
    11. ' ****************
    12. Private Sub Form_Load()
    13.     cmdSave.Enabled = False
    14.     cmdSave.Visible = False
    15.     cmdCancel.Caption = "Close"
    16.     frmMain.Visible = False ' for some reason my other mdi form shows up  :ehh:
    17. End Sub
    18.  
    19. Public sub PopMatEdit (ByVal myMatToEdit As Integer)
    20. ' I retireve data from a database and use "rs" as the recordset (not needed for this question)
    21. If IsNull(rs.Fields("Date").Value) = True Then
    22.     txtDate.Text = ""
    23. Else
    24.     txtDate.Text = rs.Fields("Date").Value
    25. End If
    26. End Sub
    27.  
    28. Private Sub txtDate_Change()
    29. If lblDateChck.Caption <> txtDate.Text Then
    30.     Call ButtonChange
    31.     MsgBox "txtDate_Change"
    32. End If
    33. End Sub
    34.  
    35. Private Sub ButtonChange()
    36.     cmdSave.Enabled = True
    37.     cmdSave.Visible = True
    38.     cmdCancel.Caption = "Cancel"
    39. End Sub
    every time the form loads, it triggers the msgbox and "ButtonChange" has obviously triggered.
    BeengieHappy.Vaue = (SharksScore > OpponentsScore)

    Go Sharks!

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Change event with form load

    I don't see where you are incorporating vbasicgirl's suggestion of using a Boolean, so how is her suggestion not working?

  8. #8
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: Change event with form load

    beengie, i dont see a boolean anywhere in your code. The reason you MDI form shows up is because frmMain is an mdi child.

  9. #9

    Thread Starter
    Addicted Member Beengie's Avatar
    Join Date
    Nov 2003
    Location
    Central Valley, CA
    Posts
    243

    Re: Change event with form load

    I tried the code and then removed it. that is why I included the code.
    BeengieHappy.Vaue = (SharksScore > OpponentsScore)

    Go Sharks!

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