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