Consulting

Results 1 to 7 of 7

Thread: Solved: form load event not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Solved: form load event not working

    Hello,

    I need to populate a text box once the form it is on loads. Its form loads when the user clicks a button on a different form. I want to populate it with a global variable (a double).

    The program calculates a flow rate. The user enters some parameters on one form (VariableEntry), clicks "calculate", which gives the variable FlowRate a value and loads the next form (Conclusion). I want that form to contain a text box (FlowRateBox) with the variable FlowRate displayed.

    In a module, I have:

    [vba]Global FlowRate As Double[/vba]
    In the code thing for the first form (VariableEntry), I have:

    [vba]Private Sub Calculate_Click()
    If Not ReynoldsNumberBox.Text = "" And Not PressureBox.Text = "" And Not DiameterBox.Text = "" And Not ViscosityBox.Text = "" And Not PipeLengthBox.Text = "" Then
    P = Val(PressureBox.Text)
    D = Val(DiameterBox.Text)
    V = Val(ViscosityBox.Text)
    L = Val(PipeLengthBox.Text)
    Const PI As Double = 3.14159265358979
    FlowRate = (PI * P * D ^ 4) / (128 * V * L)
    Unload VariableEntry
    Conclusion.Show
    Else
    MsgBox "All fields must contain data before flow rate can be calculated"
    End If
    End Sub[/vba]
    I have been trying this in the code section for the Conclusion form, but it's not working...the text box is just empty:

    [vba]
    Private Sub Conclusion_Load()
    FlowRateBox = FlowRate
    End Sub[/vba]
    I hope I've provided enough information/been clear enough. Thanks. =)

    edit:

    I think the problem is with the Load() event. Even if I do something like

    [vba]Private Sub Conclusion_Load()

    MsgBox "Hello"

    End Sub[/vba]

    the message box doesn't pop up. Is there some trick to getting the load event to work?
    Last edited by franzkafka; 12-06-2008 at 07:56 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
  •