Hi there,

I am having trouble with public variables.

I am trying to create a public variable when a button is pressed. and then recall it on a different form. I cant seem to get it working.

The code on form 1 is:

Private Sub cmdstu_Click()

fmpay1.Text1 = "Students"
fmpay1.Text2 = "0.80"
strtype = "students"
fmdest1.Show
fmticket.Hide

End Sub

on the module: Public strtype As String

on the second form:

Private Sub Form_Load()

    txttot.Text = strtype

End Sub

Ideally what I am trying to do is capture what was pressed and then add it into a shopping basket type environment of the second form. I can get the detail to show using the

fmpay1.Text1 = "Students" line but then when I try to make it back into a sting it doesnt work strtype = Text1.Text

any ideas ?

Its hard for me to follow which forms are which in your example. However, you can use
Use fmticket.Text1.Text = fmpay1.Text1.Text to have one form's text box use the value of the other.

Its hard for me to follow which forms are which in your example. However, you can use
Use fmticket.Text1.Text = fmpay1.Text1.Text to have one form's text box use the value of the other.

hello,
i got that bit working, where i have the problem is when i want to make the fmpay1,text into a string


i cant use the public var. to take it from the first form fmticket

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.