Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

form to form referencing...

dgm6780dgm6780 Member Posts: 2
I am pretty new to VB, just needed to get that out of the way. I am using an mdi form with a 3 button toolbar. The program starts with the mdi form + my home form. In my home form there are 2 option buttons. I want my buttons on the mdi form to show different things depending on which option was selected on the home form.

code from the home form:

Public Sub Command1_Click()

If opt15pt = True Then
service = 1

ElseIf optBasic = True Then
service = 2

Else
MsgBox ("Please choose the service level for this ")
End If

End Sub


***and code where I try to reference service in the button on the MDI form****

Private Sub Command1_Click()
If service = 1 Then
Upper.Show
Lower.Hide
Courtesy.Hide
ElseIf service = 2 Then
LofUpper.Show
lofLower.Hide
lofCourtesy.Hide
Else
MsgBox ("Still Not Working")
End If
End Sub


Any help is appreciated, right now the only place I have "service" declared is in the general area of the home form. I have been reading about how to build classes, is building a class the only way I am going to be able to get this to work?

Thanks
DGM

Comments

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    You've kinda lost me, but I think what you want is:

    [italic]FormName.ControlName.Property[/italic]

    Basically, to reference the toolbar on another form, you need to start with the name of the form.

    MDIForm1.Toolbar1......

    : I am pretty new to VB, just needed to get that out of the way. I am using an mdi form with a 3 button toolbar. The program starts with the mdi form + my home form. In my home form there are 2 option buttons. I want my buttons on the mdi form to show different things depending on which option was selected on the home form.
    :
    : code from the home form:
    :
    : Public Sub Command1_Click()
    :
    : If opt15pt = True Then
    : service = 1
    :
    : ElseIf optBasic = True Then
    : service = 2
    :
    : Else
    : MsgBox ("Please choose the service level for this ")
    : End If
    :
    : End Sub
    :
    :
    : ***and code where I try to reference service in the button on the MDI form****
    :
    : Private Sub Command1_Click()
    : If service = 1 Then
    : Upper.Show
    : Lower.Hide
    : Courtesy.Hide
    : ElseIf service = 2 Then
    : LofUpper.Show
    : lofLower.Hide
    : lofCourtesy.Hide
    : Else
    : MsgBox ("Still Not Working")
    : End If
    : End Sub
    :
    :
    : Any help is appreciated, right now the only place I have "service" declared is in the general area of the home form. I have been reading about how to build classes, is building a class the only way I am going to be able to get this to work?
    :
    : Thanks
    : DGM
    :

  • dgm6780dgm6780 Member Posts: 2
    What I am trying to do is reference an option button from my home form with my mdi form's toolbar. I want the toolbar, which is on the mdi form, to display different things depending on which option was selected on the home form. So the question is how to call a variable, which is defined in the home form, with my mdi form's toolbar.

    heh not sure if that cleared up what i am asking at all...



    : You've kinda lost me, but I think what you want is:
    :
    : [italic]FormName.ControlName.Property[/italic]
    :
    : Basically, to reference the toolbar on another form, you need to start with the name of the form.
    :
    : MDIForm1.Toolbar1......
    :
    : : I am pretty new to VB, just needed to get that out of the way. I am using an mdi form with a 3 button toolbar. The program starts with the mdi form + my home form. In my home form there are 2 option buttons. I want my buttons on the mdi form to show different things depending on which option was selected on the home form.
    : :
    : : code from the home form:
    : :
    : : Public Sub Command1_Click()
    : :
    : : If opt15pt = True Then
    : : service = 1
    : :
    : : ElseIf optBasic = True Then
    : : service = 2
    : :
    : : Else
    : : MsgBox ("Please choose the service level for this ")
    : : End If
    : :
    : : End Sub
    : :
    : :
    : : ***and code where I try to reference service in the button on the MDI form****
    : :
    : : Private Sub Command1_Click()
    : : If service = 1 Then
    : : Upper.Show
    : : Lower.Hide
    : : Courtesy.Hide
    : : ElseIf service = 2 Then
    : : LofUpper.Show
    : : lofLower.Hide
    : : lofCourtesy.Hide
    : : Else
    : : MsgBox ("Still Not Working")
    : : End If
    : : End Sub
    : :
    : :
    : : Any help is appreciated, right now the only place I have "service" declared is in the general area of the home form. I have been reading about how to build classes, is building a class the only way I am going to be able to get this to work?
    : :
    : : Thanks
    : : DGM
    : :
    :
    :

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    As I said, you simply have to refer to the option buttons by prefixing the name of the form they are on. Set them visible or not, change the captions, etc.

    Now if it's a variable you are after and not an option button, you need to make the variable Public at the top of the form (General Declarations) and then refer to it by:

    FormName.VariableName = Value

    : What I am trying to do is reference an option button from my home form with my mdi form's toolbar. I want the toolbar, which is on the mdi form, to display different things depending on which option was selected on the home form. So the question is how to call a variable, which is defined in the home form, with my mdi form's toolbar.
    :
    : heh not sure if that cleared up what i am asking at all...
    :
    :
    :
    : : You've kinda lost me, but I think what you want is:
    : :
    : : [italic]FormName.ControlName.Property[/italic]
    : :
    : : Basically, to reference the toolbar on another form, you need to start with the name of the form.
    : :
    : : MDIForm1.Toolbar1......
    : :
    : : : I am pretty new to VB, just needed to get that out of the way. I am using an mdi form with a 3 button toolbar. The program starts with the mdi form + my home form. In my home form there are 2 option buttons. I want my buttons on the mdi form to show different things depending on which option was selected on the home form.
    : : :
    : : : code from the home form:
    : : :
    : : : Public Sub Command1_Click()
    : : :
    : : : If opt15pt = True Then
    : : : service = 1
    : : :
    : : : ElseIf optBasic = True Then
    : : : service = 2
    : : :
    : : : Else
    : : : MsgBox ("Please choose the service level for this ")
    : : : End If
    : : :
    : : : End Sub
    : : :
    : : :
    : : : ***and code where I try to reference service in the button on the MDI form****
    : : :
    : : : Private Sub Command1_Click()
    : : : If service = 1 Then
    : : : Upper.Show
    : : : Lower.Hide
    : : : Courtesy.Hide
    : : : ElseIf service = 2 Then
    : : : LofUpper.Show
    : : : lofLower.Hide
    : : : lofCourtesy.Hide
    : : : Else
    : : : MsgBox ("Still Not Working")
    : : : End If
    : : : End Sub
    : : :
    : : :
    : : : Any help is appreciated, right now the only place I have "service" declared is in the general area of the home form. I have been reading about how to build classes, is building a class the only way I am going to be able to get this to work?
    : : :
    : : : Thanks
    : : : DGM
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.