Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, This probably a very simple 2

Status
Not open for further replies.

TheGov

IS-IT--Management
Jan 25, 2002
18
GB
Hi,

This probably a very simple question, but I am new to VFP. How do you display variables on a form?

I have a main form with an option group on it, and I want to display which option was selected on all subsequent forms. The value of the option group is stored in a variable, which is picking up the value from the og according to the Locals window. I have put a text box on a form, but the variable is not on the ControlSource drop down list. I can see the variable when I use the fx button next to the entry box, but when I run the form I get 'Data type mismatch'.

Thanx in advance
Pete
 
Hi
The variable you are associating to store may be local. This may not be public.

SO, before starting the form from Main.prg..
PUBLIC myOg
OR
PRIVATE myOg
OR
myOg=0
DO FORM myMainForm

Then in the MainFoprm.. you store the optionGroup Choice value into this
myOg = whatever.

This variable myOg will be available in all subsequent forms.
:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi Ramani

Thanks for the reply.

This seems to make sense, but on trying it, I still have the same problem, no variables in the dropdown list.

Pete

PS Sorry about missing the subject line out!
 
It sounds like you are confusing controls here. An option group is a set of radio buttons (the circles with the dot in the middle) and the drop down list is a list box or combo box. Maybe I'm being picky but there is a lot of different coding behind the scenes for each.
Anyway, if you have a control on one form that you want to reference in another, it can either be a public variable like ramani said, or you can reference it by using the form's name that the control was set in:

Form1.ogMyOption.Value
-or-
Form1.cbMyCombo.DsiplayValue

and so on.
Dave S.
 
Sorry, hit the button too quick.
For setting a value of say a textbox on another form, those should read:

ThisForm.Text1.Value = m.MyPublicVar
-or-
ThisForm.Text1.Value = Form1.ogMyOption.Value
-or-
ThisForm.Text1.Value = Form1.cbMyCombo.DsiplayValue
Dave S.
 
Hi Dave,

The dropdown list I was refering to is the one that appears in the property window when you edit the ControlSource, which is where I expected to find a list of available variables.

Anyway, with a combination of your's and Ramani's tips I've got it sorted. I did not realise that I had to use the expression builder to get the list of variables, which now shows my global variable, or as you said, I can reference the form directly.

I was also trying to concatenate a string and a number, which was giving the data error. I am used to declairing variable data types and would have used a char to store the number, but I found the str() command.

This is a very strange language!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top