ibbm


I have a form that collects data and when the user clicks on "Confirm"

I'm trying to run an update.prg which is called by many other routines in my application. Rather than add a whole lot of methods to the form I was hoping I could use this program. I am newbie to OOP so maybe I am taking the whole wrong approach.

I have added properties to my form that i want to access. In particular one called oRecord. This holds data from a scatter name oRecord.

In my update.prg program I am trying to access this form to use it's properties.

At the very beginning of the update.prg I was suggested to use

If type("_screen.ActiveForm.frmBaseOrder") = "C" and pemstatus('oNewRecord',_screen.ActiveForm,5)
oform = _screen.ActiveForm.frmBaseOrder
endif

but it's not working at all. It doesn't pass the conditions.

Any suggestions When I use the debugger the value of the type() command is a "U" and I can't get anything for the pemstatus() I see all the objects in the debugger so I'm assuming that my form must still be active.

Thanks. Should I be making my programs that I want to call as a separate object somewhere and how do I do that

Thanks in advance.




Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

Naomi Nosonovsky


ibbm wrote:

At the very beginning of the update.prg I was suggested to use

If type("_screen.ActiveForm.frmBaseOrder") = "C" and pemstatus('oNewRecord',_screen.ActiveForm,5)
oform = _screen.ActiveForm.frmBaseOrder
endif

but it's not working at all. It doesn't pass the conditions.

No, I didn't suggest it to use as you wrote. I suggested a slightly different syntax:

Code Snippet

If type("_screen.ActiveForm.name") = "C" and pemstatus('oRecord',_screen.ActiveForm,5)
oform = _screen.ActiveForm && we now have a reference to a

form in a oForm variable

oRecord = oForm.oRecord && we have a record reference now too in a variable

endif

In other words, we're testing, if we have an active form and if this form has a property oRecord. Perhaps we also need to test, if the form's name is the one we want to update (what if you have a different form active at the moment )






Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

dni

You may try to use .AND. or .and. instead and.





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

ibbm

It doesn't pass the test. and I tried both and and .and. is there somehow to trap it.

The value for the type() is "U" and I don't know how to trap the pemstatus.





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

CetinBasoz

Not all forms are members of _screen, you may need _vfp instead. ie:

if type('_vfp.activeform') ='O' and !isnull('_vfp.activeform')

loForm = _vfp.ActiveForm

*...

endif

But I'd instead pass form's reference to update method:

*Confirm click

Update(thisform)

*Update

lparameters toForm





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

dni

You are trying to test a property and you should have a value for property to use with type. So you may add ".Value" to the first if condition... something like:

type("_screen.ActiveForm.frmBaseOrder.Value")






Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

Naomi Nosonovsky

Yes, I also suggested to just pass thisform to an update program as a parameter in a previous thread.

It is also always simple to just check .ActiveForm.Name insted of two checks. If the form is not null, the name is of type C.





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

ibbm

when i try passing the parameter to the program

update(thisform)

and in my update my first statement is

parameter oform

I get

No parameter statement is found.

what am I doing wrong btw you have given me new insight into objects and i really appreciate that.





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

Naomi Nosonovsky

Don't name your program UPDATE. It's a reserved VFP/SQL word and you may get into trouble. Name it something like form_Update.

Also make sure the previous line before parameters (BTW, I prefer lparameters to create local vars instead of private) does not end on semicolon.





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

ibbm

actually the name of the program is "udupdate" but something must have happened to it so I renamed it and it works! plus i change the parameters to lparameters

A thousand thank yous. I should be on my way.... for a couple more hours anyway!





Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

Naomi Nosonovsky

You're welcome.



Re: I am trying to use a form's properties in a program but i am having trouble accessing the active form.

Tamar E. Granor

<<You may try to use .AND. or .and. instead and.>>

This makes no difference whatsoever. The periods are totally optional and in all the years since that became true, I've never since a case where .AND. worked and AND (with a space on either side) didn't.

Tamar