Results 1 to 6 of 6
  1. #1
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94

    Setting a variable on one bound form from another table

    I have a start_page form which sets temporary variables from several tables which do not have a relationship. The start_page form is bound to tbl_one and I need to set a variable based on tbl_two.data where tbl_two.column_one = "version"

    I would like to do so from a VBA script on the start_page form if possible without opening another form which is bound to tbl_two.

    How can I go about doing that?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,433
    One way would be a DLookup:

    DLookup Usage Samples

    Another would be a recordset.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    OK great - I got a return value with:

    <code>MsgBox "DRC Version: " & DLookup("Data", "qry_DRCConfig", "Child = 'Version'")</code>

    Now I am having difficulties assigning that to a tempvar.

    <code>TempVars.Add "varAppVersion", DLookup("Data", "qry_DRCConfig", "Child = 'Version'")</code>

    Returns a #Name? error

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,433
    I don't use TempVars, but this worked in a brief test in a test db:

    TempVars.Add "paultest", DLookup("IDField", "tblData", "TextField = 'Test2'")
    MsgBox TempVars!paultest
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    I figured it out. Thanks for the help. The TempVar solution was to refer to it with an ! instead of a .

    Correct Syntax: MsgBox "DRC Version via tempvar: " & TempVars!varAppVersion, 0

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,433
    Looks like we were posting at the same time. Glad you sorted it out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-24-2012, 03:11 PM
  2. Bound form with bound combobox
    By Jerry8989 in forum Access
    Replies: 2
    Last Post: 12-05-2011, 01:50 PM
  3. Replies: 2
    Last Post: 08-05-2011, 04:41 PM
  4. Setting Temporary Variable
    By KEVWB in forum Access
    Replies: 1
    Last Post: 02-07-2011, 01:41 PM
  5. Replies: 3
    Last Post: 10-09-2010, 11:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums