Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LoadFromText clears instance variables

10 views
Skip to first unread message

bm

unread,
Aug 26, 2003, 11:02:48 AM8/26/03
to
Hello,
I have been using LoadFromText method fine until recently
when I found that call to LoadFromText clears form's
instance variable.

Here is code from my simple form with one button and load
method setting form instance variable to some value. First
click on the button will produce message with some value.
Second click on this button will produce empty message.

Private test As String

Private Sub Command0_Click()
MsgBox test

Application.LoadFromText acForm, "frm_Forms", "C:\My
Documents\\Form\frm_Forms.txt"

End Sub

Private Sub Form_Load()
test = "some value"
End Sub

I also noticed that call to LoadFromText changes or does
something to form variable set to instance of an object.

I would like to know why LoadFromText called from one form
to load another form changes (clears) one form's instance
variables? Is there a work around it?

thanks
bm

JohnFol

unread,
Aug 26, 2003, 11:11:38 AM8/26/03
to
I cannot find a LoadFromText method of the application object. What version
are you using?


"bm" <bm@dnn> wrote in message
news:0d4601c36be3$1cea9630$a501...@phx.gbl...

Dirk Goldgar

unread,
Aug 26, 2003, 10:12:00 PM8/26/03
to
"JohnFol" <Wib...@wobble.com> wrote in message
news:OgYaFS%23aDH...@TK2MSFTNGP10.phx.gbl

> I cannot find a LoadFromText method of the application object. What
> version are you using?

It's a hidden method. You can set the Object Browser to show hidden
members, and you'll see it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Dirk Goldgar

unread,
Aug 26, 2003, 10:12:07 PM8/26/03
to
"bm" <bm@dnn> wrote in message
news:0d4601c36be3$1cea9630$a501...@phx.gbl

Offhand I'd say that the method probably either *has* to reset the VB
project because the form you're importing has a code module, or else it
does it anyway just because the form *might* have a code module. I very
much doubt you can keep this from happening, in which case your only
workaround is to find a way to persist your instance variables. The
most obvious way to do this would be to save their values in a table and
reload them from there after the import.

SaveAsText and LoadFromText being undocumented methods (though
admittedly handy), do you think it's a good idea to build any
application features on them?

0 new messages