Results 1 to 5 of 5
  1. #1
    nigelbloomy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    51

    Pull text from another table

    I have a form which pulls information from an audit table. In the title of the form (in a field called TopLevel) I would like to show the top level part number where all of the auditing occurred. I have another table (the entry form table) which just has one record which contains the top level part number.
    When I try to put the part number from the entry form table into the control source for the form title, it just returns an error in the field.
    I tried writing the following code but it gives me an object error:

    Code:
    Private Sub Form_Load()
        Dim rsParent As DAO.Recordset
        
        Set rsParent = dbCurrent.OpenRecordset("Entry Form Table", dbOpenTable)
        Forms![Audit Form]![TopLevel] = rsParent!Part_Number
    End Sub
    I think I am making this more complicated than it needs to be.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    dbCurrent should be CurrentDb. You could also use a DLookup, but what you have should work with that fix.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Oh, and don't forget

    Set rsParent = Nothing
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    nigelbloomy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    51
    That works perfectly. I had copied the format from a place where the code defined a variable called dbCurrent as Currentdb. I didn't notice the switch.
    I will add in the code to set it to nothing and close it as well.

    Thank you for your help.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help.
    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. Pull Data from another table
    By bbranco in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:15 AM
  2. Replies: 2
    Last Post: 09-13-2011, 11:21 AM
  3. pull up data from a table into a form
    By MattD00 in forum Forms
    Replies: 1
    Last Post: 03-30-2011, 08:15 AM
  4. Add & Pull Records from Table via Form
    By sujitshukla in forum Programming
    Replies: 1
    Last Post: 08-02-2010, 05:51 PM
  5. Pull all text that preceeds a /
    By ahightower in forum Queries
    Replies: 3
    Last Post: 01-27-2009, 09:36 AM

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