Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006
    Posts
    2

    Search a SUBFORM & return corresponding values in MAINFO

    Hi! New here to the forum - please help! I've worked with Access off & on for years, but this one is REALLY stumping me (I have a couple other issues, but let's cover the big one first). I am working in a form that holds the primary data for shipping (entry ID, date expected, date delivered, vendor, etc). This MAINFORM has 3 subforms. I have done this because there are multiple one to many relationships. The users want to perform searches based on the SUBFORM. I do currently have the SUBFORM linked to the MAINFORM via the parent / child values.

    For example, I have an Invoice SUBFORM that shows multiple invoice numbers & amounts that correspond to the MAINFRM entry ID. I need to implement the capability to search for an Invoice number in the Invoice SUBFORM & return the corresponding MAINFORM values. Does this make sense? Can anyone help?



    Thx! Page

  2. #2
    Join Date
    Dec 2006
    Posts
    2

    Solved problem myself

    Thought I'd post the answer in case anyone else has same issue. Placed a command button on my main form with Event Procedure as follows...

    ----------------------------------------------------------------------
    Private Sub cmdSearchContainers_Click()
    On Error GoTo Err_cmdSearchContainers_Click

    DoCmd.OpenForm "f-Master Data Table Entry New", acNormal
    Me.RecordSource = "q-Search Containers"

    Exit_cmdSearchContainers_Click:
    Exit Sub

    Err_cmdSearchContainers_Click:
    MsgBox Err.Description
    Resume Exit_cmdSearchContainers_Click

    End Sub
    ------------------------------------------------------------------------------

    In addition, I created a query called "q-Search Containers" with the following SQL....

    -----------------------------------------------------------------------------

    SELECT [t-Master Data Table New].*
    FROM [t-Master Data Table New] INNER JOIN [t-Containers] ON [t-Master Data Table New].[System Number] = [t-Containers].[Master Record Number]
    WHERE ((([t-Containers].[Container Number])=[Entered the Container Number for which you are searching]));

    ------------------------------------------------------------------------------

    In short, this opens the master form with the specific container number specified by the user. I also created a similar button to "View All Records" which opens the master form with all records. This way, users can easily find a specific record & then return to all records.

    ------------------------------------------------------------------------------

    Private Sub cmdViewAllRecords_Enter()
    On Error GoTo Err_cmdViewAllRecords_Enter

    DoCmd.OpenForm "f-Master Data Table Entry New", acNormal
    Me.RecordSource = "q-form - Master Data Table Entry New"

    Exit_cmdViewAllRecords_Enter:
    Exit Sub

    Err_cmdViewAllRecords_Enter:
    MsgBox Err.Description
    Resume Exit_cmdViewAllRecords_Enter

    End Sub

    -----------------------------------------------------------------------------------

    This is the only way that I could find to open a form based on a search of a record in a subform.

    Thanks

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

Similar Threads

  1. stored procedure return value to access form
    By rbw940 in forum Programming
    Replies: 0
    Last Post: 10-13-2008, 01:31 PM
  2. Return Record # In Query
    By redwinger354 in forum Access
    Replies: 1
    Last Post: 09-15-2007, 01:08 PM
  3. Best Way to Return a Newly Created Index?
    By Jerimiah33 in forum Programming
    Replies: 5
    Last Post: 09-06-2006, 12:22 PM
  4. Return records not updated by update query
    By ars80 in forum Queries
    Replies: 2
    Last Post: 05-01-2006, 09:23 AM
  5. Replies: 1
    Last Post: 12-10-2005, 04:52 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