Results 1 to 5 of 5
  1. #1
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32

    Searching for Fields of Subform

    Suppose i have Mainform and Subform as show in thisimage.
    Now i trying to serching for SubformID=6 when i am on
    MainformID=2 and if i found SubformID=6 then i wish to goto that perticular MainformID (e.g.MainformID=1).


    Using find and replace it couldn't be done.
    please suggest me proper way

    i have also read this thread but can't getting it.
    i am looking for something nice solution for this.
    Download Sample Project
    Click image for larger version. 

Name:	Question Subform2.jpg 
Views:	17 
Size:	212.6 KB 
ID:	20470

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Can you post a copy of your db
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    keviny04 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    128
    pritesharyan, you need to add a command button on the main form with the following code:

    Code:
    Private Sub cmdFindSubformID_Click()
        Dim s As Variant, m As Variant
        
        ' Prompt for SubformID to find
        s = InputBox("Find SubformID:")
        
        ' Show error if entry is not numeric
        If Not IsNumeric(s) Then
            MsgBox "Invalid entry."
                
        Else
            
            ' Get MainformID
            m = DLookup("[MainformID]", "Subform", "[SubformID]=" & s)
            
            ' m = null: nothing found, tell user
            If IsNull(m) Then
                MsgBox "No MainformID found."
            
            Else
                ' m not null: MainformID found, move to record on main form
                Me.Recordset.FindFirst "[MainformID]=" & m
            End If
            
        End If
        
    End Sub
    This code prompts the user to enter a SubformID, tests for valid entry, finds the corresponding MainformID (with the Dlookup() function), and moves to the main form's record for MainformID. I attached the modified sample database here: Search Subform.zip

  4. #4
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32
    thank you so much @keviny04 this is what exactly i am looking for thank you so much

  5. #5
    pritesharyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    India
    Posts
    32
    i have provided see updated question btw now question is solved thanks for answering.

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

Similar Threads

  1. Searching a record through the subform
    By Ruegen in forum Forms
    Replies: 5
    Last Post: 10-28-2013, 09:46 PM
  2. Searching Subform from Mainform Combobox
    By Padstar in forum Access
    Replies: 1
    Last Post: 10-25-2012, 12:45 PM
  3. Searching by field on subform on main form
    By helen21112010 in forum Forms
    Replies: 1
    Last Post: 10-16-2012, 07:55 AM
  4. Searching a Subform
    By desireemm1 in forum Forms
    Replies: 5
    Last Post: 10-03-2011, 06:01 PM
  5. Searching through a subform on a form
    By HarryScofs in forum Access
    Replies: 10
    Last Post: 08-01-2011, 03:37 PM

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
  •  
Other Forums: Microsoft Office Forums