subform loses internal value

G

Guest

I have a form which has a subform.

The subform has a private variable, declared at the top of the code so it
should have (sub)form-wide scope:
Private lngCoID as long

The subform loads first, in the process of which it sets (in the load event)
the value of the private variable as in:
lngCoID = (value I fetched when I started up)

This value is available to the outside world through a property of the
subform, as:
Property Get Coid() As Long
Coid = lngCoID
End Property

In the form_load event of the main form, the main form asks the subform for
the value, as:
id = Form_subform.Coid

The funny thing is, when the main form, in it's load event, asks the subform
what the value in question is, the subform returns 0, even though when it
loaded and set lngCoid, the value originally was not 0!

What happened to the value of lngCoID between the time the subform set it,
and the time the main form asked for it?

Thanks in advance for any help.

Fred
 
A

Arvin Meyer [MVP]

0 is also False, and that's what the subform is probably returning. Just for
giggles, try declaring lngCoID as a Public (Global) variable and have your
code do a: Debug.Print to record the value.
 
G

Guest

Thanks for your reply

It is returning a datatype long as in the property description; I use this
technique a lot and really like using properties to provide information to
the outside world. I stepped through the code in debug mode and indeed the
subform insistes the value is 0. I will try redefining lngCoID as public to
see what happens on Monday.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top