Results 1 to 3 of 3

Thread: Form load data before showdialog

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2009
    Posts
    26

    Form load data before showdialog

    I have problems with a form and load event.

    My form manage items that can be added, deleted or modified. In load code, I initialize all vars to cero. This is OK to be ready to add items.

    My problem is with modify and delete. To carry this, I must load vars from a source. So, in my foreing code I have this:

    Code:
          Dim frm As newMyForm
            frm = New newMyForm()
            Dim resultado As Boolean = frm.duplicar("0003")
            If (resultado = False) Then
                MsgBox("Could not open 0003")
                frm.Close()
                Return
            End If
            frm.ShowDialog()
            Me.Close()
    frm.duplicar load data based on 0003 as index.
    My problem is that when showdialog is called, all data which were loaded from duplicar funct is put again to cero. How can I avoid this and load correct data into the form.

    Thanks

  2. #2
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: Form load data before showdialog

    Have you stepped through the code to make sure that the data is indeed being cleared? Once you load data, it doesn't just disappear.
    From my burrow, 2 feet under.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Form load data before showdialog

    You say that this:
    In load code, I initialize all vars to cero.
    Does that mean in the Load event handler of the form? The Load event handler is not executed until you LOAD the form, not when you CREATE the form. That means the Load event handler is executed AFTER you call ShowDialog.

    Why do you need any code to set anything to zero anyway? It's a brand new form so everything is zero by default and will only have some other value if you set it so.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

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