rl*********@yahoo.com wrote:
I have an application where App1.mdb calls App2.mdb when a button is
clicked on a form.
App1 has three values of interest:
1. gblPgmPath
2. frmMain1.txtSubTotalVariance
3. frmMain1.txtSubTotalVariancePct
The two txt fields are calculated realtime.
When App2 is launched from App1, App1 has frmMain1 open and stays open
even after work in App2 is completed and closed.
App1 has a value in the gblPgmPath variable and two values in text
boxes in frmMain1 that App2 needs to reference.
Over in App2, what is the syntax for referencing the "gbl" variable
and the two text boxes in frmMain1 so that I can retrieve their values
successfully?
When you say "App1.mdb calls App2.mdb" - what does that mean exactly?
There are several ways you could accomplish this but you won't (easily)
be able to get the values of variables in another instance of Access.
But, its trivial to use SQL to write values from one .mdb to another.
For example - in code you could do this from App1.mdb (regardless of
whether App2.mdb is open or not):
CurrentDB.Execute "UPDATE PassedParameters IN '" & CurrentProject.Path & _
"\App2.mdb' SET PgmPath = '" & gblPgmPath & "';", dbFailOnError
Some assumptions: App2.mdb is in the same folder as App1.mdb (if not
then remove "CurrentProject.Path" and replace with the path.
Your PassedParameters table in App2.mdb has only one row otherwise
you'll most likely want to limit what rows are updated by using a WHERE
clause in the SQL.
And.. your PassedParameters has at least one row (or the SQL will fail).
You should add error handling in your code anyway.
I also didn't deal with the form values but the example should give you
the general idea.
Another method would be to write values to a text or XML file from App1
and read them in App2.
--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------