Object property persistance 
Author Message
 Object property persistance

I want to assign a property value to a .dll in one form action, as in
'myObj. prop = strValue, have another form popup and perform a function
based on the afore mentioned objects property value. During this process the
first form remains open and loaded, the object should still be open (hasn't
been explicitly closed or set to nothing). Yet when I try to access the
propety in the second form it is an empty string. Am I missing something
basic? Any comments welcome. TIA.


Sun, 28 Dec 2003 23:23:20 GMT  
 Object property persistance
Glen,

Please post the code. How do you instantiate the object? Are you sure that
both forms have access to the same instance?

--
Best regards,
Alexander Shirshov, MCSD


Quote:
> I want to assign a property value to a .dll in one form action, as in
> 'myObj. prop = strValue, have another form popup and perform a function
> based on the afore mentioned objects property value. During this process
the
> first form remains open and loaded, the object should still be open
(hasn't
> been explicitly closed or set to nothing). Yet when I try to access the
> propety in the second form it is an empty string. Am I missing something
> basic? Any comments welcome. TIA.



Mon, 29 Dec 2003 01:31:43 GMT  
 Object property persistance
Your right, I'm re-instantiating the object upon opening the second form. So
I guess I need to know how to persist(?) the object from one form to
another. Should I do in IF statement or something?
Some thing like
    if objJob state = open then
        <continue loading form>
    else
        set objJob = new MyDll.Job
    end if
(Please excuse the pseudo code)


Quote:
> Glen,

> Please post the code. How do you instantiate the object? Are you sure that
> both forms have access to the same instance?

> --
> Best regards,
> Alexander Shirshov, MCSD



> > I want to assign a property value to a .dll in one form action, as in
> > 'myObj. prop = strValue, have another form popup and perform a function
> > based on the afore mentioned objects property value. During this process
> the
> > first form remains open and loaded, the object should still be open
> (hasn't
> > been explicitly closed or set to nothing). Yet when I try to access the
> > propety in the second form it is an empty string. Am I missing something
> > basic? Any comments welcome. TIA.



Mon, 29 Dec 2003 22:07:33 GMT  
 Object property persistance
Hi Glen,

You could use a global variable in this way. Alternatively, you could add a
new method to the second form that sets the object and shows itself.

e.g. (in Form2.frm)

Sub DoShow(ByVal objJob As Job)
    Set mobjJob = objJob
    Me.Show
End Sub

where mobjJob is a form local variable of type Job. In this way, you can use
mobjJob in any of the form events, but don't forget to set it back to
Nothing either when you hide or unload the form.

Hope this helps.

Best regards,

Ade.


Quote:
> Your right, I'm re-instantiating the object upon opening the second form.
So
> I guess I need to know how to persist(?) the object from one form to
> another. Should I do in IF statement or something?
> Some thing like
>     if objJob state = open then
>         <continue loading form>
>     else
>         set objJob = new MyDll.Job
>     end if
> (Please excuse the pseudo code)



> > Glen,

> > Please post the code. How do you instantiate the object? Are you sure
that
> > both forms have access to the same instance?

> > --
> > Best regards,
> > Alexander Shirshov, MCSD



> > > I want to assign a property value to a .dll in one form action, as in
> > > 'myObj. prop = strValue, have another form popup and perform a
function
> > > based on the afore mentioned objects property value. During this
process
> > the
> > > first form remains open and loaded, the object should still be open
> > (hasn't
> > > been explicitly closed or set to nothing). Yet when I try to access
the
> > > propety in the second form it is an empty string. Am I missing
something
> > > basic? Any comments welcome. TIA.



Mon, 29 Dec 2003 22:21:23 GMT  
 Object property persistance
I'd thought of doing something similar but I shy away from globals. Your
second suggestion is intriguing but I don't see where the object value I set
in form1 is persisted to form2.


Quote:
> Hi Glen,

> You could use a global variable in this way. Alternatively, you could add
a
> new method to the second form that sets the object and shows itself.

> e.g. (in Form2.frm)

> Sub DoShow(ByVal objJob As Job)
>     Set mobjJob = objJob
>     Me.Show
> End Sub

> where mobjJob is a form local variable of type Job. In this way, you can
use
> mobjJob in any of the form events, but don't forget to set it back to
> Nothing either when you hide or unload the form.

> Hope this helps.

> Best regards,

> Ade.



> > Your right, I'm re-instantiating the object upon opening the second
form.
> So
> > I guess I need to know how to persist(?) the object from one form to
> > another. Should I do in IF statement or something?
> > Some thing like
> >     if objJob state = open then
> >         <continue loading form>
> >     else
> >         set objJob = new MyDll.Job
> >     end if
> > (Please excuse the pseudo code)



> > > Glen,

> > > Please post the code. How do you instantiate the object? Are you sure
> that
> > > both forms have access to the same instance?

> > > --
> > > Best regards,
> > > Alexander Shirshov, MCSD



> > > > I want to assign a property value to a .dll in one form action, as
in
> > > > 'myObj. prop = strValue, have another form popup and perform a
> function
> > > > based on the afore mentioned objects property value. During this
> process
> > > the
> > > > first form remains open and loaded, the object should still be open
> > > (hasn't
> > > > been explicitly closed or set to nothing). Yet when I try to access
> the
> > > > propety in the second form it is an empty string. Am I missing
> something
> > > > basic? Any comments welcome. TIA.



Mon, 29 Dec 2003 22:53:51 GMT  
 Object property persistance

Quote:
> I'd thought of doing something similar but I shy away from globals. Your
> second suggestion is intriguing but I don't see where the object value I
set
> in form1 is persisted to form2.

Well, you declare a variable in Form2

    Private mobjJob As Job

Then in Form1, you have code like:

Dim f As Form2

    Set f = New Form2
    f.DoShow objJob

where objJob is the reference in Form1. This is passed to Form2 as an
argument to the DoShow method. Then when Form2 closes, it can do an Unload
Me, and in the Form_Unload you Set mobjJob = Nothing.

Does this help?

Ade.

Quote:



> > Hi Glen,

> > You could use a global variable in this way. Alternatively, you could
add
> a
> > new method to the second form that sets the object and shows itself.

> > e.g. (in Form2.frm)

> > Sub DoShow(ByVal objJob As Job)
> >     Set mobjJob = objJob
> >     Me.Show
> > End Sub

> > where mobjJob is a form local variable of type Job. In this way, you can
> use
> > mobjJob in any of the form events, but don't forget to set it back to
> > Nothing either when you hide or unload the form.

> > Hope this helps.

> > Best regards,

> > Ade.



> > > Your right, I'm re-instantiating the object upon opening the second
> form.
> > So
> > > I guess I need to know how to persist(?) the object from one form to
> > > another. Should I do in IF statement or something?
> > > Some thing like
> > >     if objJob state = open then
> > >         <continue loading form>
> > >     else
> > >         set objJob = new MyDll.Job
> > >     end if
> > > (Please excuse the pseudo code)



> > > > Glen,

> > > > Please post the code. How do you instantiate the object? Are you
sure
> > that
> > > > both forms have access to the same instance?

> > > > --
> > > > Best regards,
> > > > Alexander Shirshov, MCSD



> > > > > I want to assign a property value to a .dll in one form action, as
> in
> > > > > 'myObj. prop = strValue, have another form popup and perform a
> > function
> > > > > based on the afore mentioned objects property value. During this
> > process
> > > > the
> > > > > first form remains open and loaded, the object should still be
open
> > > > (hasn't
> > > > > been explicitly closed or set to nothing). Yet when I try to
access
> > the
> > > > > propety in the second form it is an empty string. Am I missing
> > something
> > > > > basic? Any comments welcome. TIA.



Tue, 30 Dec 2003 01:00:22 GMT  
 Object property persistance
Yup. I'll give it a test drive.


Quote:


> > I'd thought of doing something similar but I shy away from globals. Your
> > second suggestion is intriguing but I don't see where the object value I
> set
> > in form1 is persisted to form2.

> Well, you declare a variable in Form2

>     Private mobjJob As Job

> Then in Form1, you have code like:

> Dim f As Form2

>     Set f = New Form2
>     f.DoShow objJob

> where objJob is the reference in Form1. This is passed to Form2 as an
> argument to the DoShow method. Then when Form2 closes, it can do an Unload
> Me, and in the Form_Unload you Set mobjJob = Nothing.

> Does this help?

> Ade.



> > > Hi Glen,

> > > You could use a global variable in this way. Alternatively, you could
> add
> > a
> > > new method to the second form that sets the object and shows itself.

> > > e.g. (in Form2.frm)

> > > Sub DoShow(ByVal objJob As Job)
> > >     Set mobjJob = objJob
> > >     Me.Show
> > > End Sub

> > > where mobjJob is a form local variable of type Job. In this way, you
can
> > use
> > > mobjJob in any of the form events, but don't forget to set it back to
> > > Nothing either when you hide or unload the form.

> > > Hope this helps.

> > > Best regards,

> > > Ade.



> > > > Your right, I'm re-instantiating the object upon opening the second
> > form.
> > > So
> > > > I guess I need to know how to persist(?) the object from one form to
> > > > another. Should I do in IF statement or something?
> > > > Some thing like
> > > >     if objJob state = open then
> > > >         <continue loading form>
> > > >     else
> > > >         set objJob = new MyDll.Job
> > > >     end if
> > > > (Please excuse the pseudo code)



> > > > > Glen,

> > > > > Please post the code. How do you instantiate the object? Are you
> sure
> > > that
> > > > > both forms have access to the same instance?

> > > > > --
> > > > > Best regards,
> > > > > Alexander Shirshov, MCSD



> > > > > > I want to assign a property value to a .dll in one form action,
as
> > in
> > > > > > 'myObj. prop = strValue, have another form popup and perform a
> > > function
> > > > > > based on the afore mentioned objects property value. During this
> > > process
> > > > > the
> > > > > > first form remains open and loaded, the object should still be
> open
> > > > > (hasn't
> > > > > > been explicitly closed or set to nothing). Yet when I try to
> access
> > > the
> > > > > > propety in the second form it is an empty string. Am I missing
> > > something
> > > > > > basic? Any comments welcome. TIA.



Tue, 30 Dec 2003 01:11:27 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Custom complex properties persistance

2. Property persistance question

3. OCX properties persistance

4. Persistance of objects

5. Object Persistance/Serialization

6. Problem with Persistance of object type between apps

7. Object persistance

8. Object Persistance and Focus

9. PublicNotCreatable object collection persistance

10. Object persistance without the PropBag?

11. Object Persistance to DB

12. someone please explain object persistance

 

 
Powered by phpBB® Forum Software