odd behavior when form embedded in other form

G

Guest

This seems to be a variable scope problem.

I have started using a particular technique for developing Access
interfaces, but it has resulted in seemingly odd behavior.

My main app form consists of a tab control with a tab page for each major
feature of my app. For example, one feature is to broadcast email messages
to certain parties. These may be emails to students that completed a course,
and the email has their completion certificate attached as a PDF doc.
Another email feature is to send student rosters and sign-in sheets to
instructors before a classroom class is held.

What I have started to do is develop each major feature within it's own
form, self contained (mostly) where I debug it and make sure everything
works. The finished app is the main form with each tabbed page having a
'feature form' (like the email form above) embedded in it.

Problem: once I embed my 'feature containing' subforms into the tabs of my
main form, my variables in the subforms seem to loose their scope. For
example, in the email subform, the variable that tells my app where to save
..PDF documents is dimensioned "Private' at the top of the form, and in the
form open statement I look up what directory PDF files should be saved in.
This works fine when I run this form by itself. However, when I go to use
that information in the email subform after it has been added to the main
form tab control, the variable is blank!

Other variables, for example ones I have declared as class variables in the
subform, work when the subform is used by itself, but return 'object or with
block variable not set' errors when the subform is embedded in the main form.
There are no naming conflicts, as all my variables between the forms are
unique.

Any ideas why my variables loose their information when my form is embedded
in another form, or, more importantly, how to make this stop happening?

Thanks in advance for any help.

Fred
 
G

Guest

Hi Fred,

are you referring to them as;

Forms!MainForm.Subform.Form.variable

or just as variable?

TonyT..
 
G

Guest

Sorry for the delay, Microsoft replys get marked as spam, I finally
white-listed this site.

I refer to the variables within a form the same was as they were created,
for example

Private strInstructorReportsFileLocation
.....
PDFFileName = strInstructorReportsFileLocation & "Roster_Class_" & ClassCode

At this point the variable is an empty string.

Thanks
 

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