Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2014
    Posts
    6

    Wink Unanswered: Passing variables between access databases

    I have an access database (access 2010) that needs to open another access database.
    When you open an access database can you pass a variable to it? Here is my vba code:


    Set appAccess = CreateObject("Access.Application")
    docAccess = appAccess.OpenCurrentDatabase("C:\users\SLC\docume nts\called.accdb", True)
    appAccess.Visible = True

    Any help will be appreciated.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    It's doable. Let's name the first database (the caller) Db1.mdb and the second (the one being called) Db2.mdb.

    1. In Db2, create a public function in a standard module, like this:
    Code:
    Public Function ArgumentReceiver(ByVal Argument As Variant)
    
        MsgBox Argument
        
    End Function
    Or course, you can do whatever you want with the received argument.

    2. In Db1, you instanciate Db2 and pass the argument to the function ArgumentReceiver(), like this:
    Code:
    Sub OpenAnotherDatabase()
    
        Dim appAccess As Access.Application
        
        Set appAccess = New Access.Application
        With appAccess
            .OpenCurrentDatabase "U:\Access\Db2.mdb"
            .Visible = True
            .Eval ("ArgumentReceiver('Hello world!')")
            .Quit
        End With
        Set appAccess = Nothing
        
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Feb 2014
    Posts
    6

    Passing variables between access databases

    Front End = Access 2010 vba
    Back End = SQL Server 2008

    New to Access ans SQL Server , with that in mind;

    I have an Access program that starts another Access program. Here is the code:

    Set appAccess = CreateObject("Access.Application")
    docAccess = appAccess.OpenCurrentDatabase("C:\users\slc\docume nts\called.accdb", True)
    appAccess.Visible = True

    Is there anyway I can pass a value to called.accdb?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    as you have an instance (object) of the Access application in one Access Applciation then you should be able to pass values to or from the applications

    eg:-

    appAccess.forms!myformname.mycontrol.text = thiscontrol.text
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2014
    Posts
    6

    Talking Thank you

    Sorry for the long response. It works. Thanks.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •