The easiest way is to set a library reference and use the public procedures,
but if you have an aversion to that, then you could open the other DB and run
a macro that runs a public function that reads your variables you've stored
in a table in the other DB. If storing the data in a table is not possible,
then you could try something like this:
Public Sub execFnInOtherDB()
On Error GoTo ErrHandler
Dim accApp As New Access.Application
Dim frm As Form
Set accApp = CreateObject("Access.Application")
accApp.OpenCurrentDatabase ("C:\MyDB.mdb")
accApp.Visible = True ' For test purposes
only.
accApp.DoCmd.OpenForm "frmSetVars"
Set frm = accApp.Forms!frmSetVars
frm.txtBestCar.Value = "Camaro"
accApp.DoCmd.RunMacro "mcrRunMyFn" ' Macro runs public function
' that reads
text box on form
' for further
processing.
Set frm = Nothing
accApp.Quit
CleanUp:
Set frm = Nothing
Set accApp = Nothing
Exit Sub
ErrHandler:
MsgBox "Error in execFnInOtherDB( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
GoTo CleanUp
End Sub
The macro, mcrRunMyFn, runs a public function that reads the value in the
text box on the open form. You would need to define the public function,
name and all. For testing purposes, set the accApp.Visible = True, but leave
this out during normal operations, because the user doesn't need to see
what's going on.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.