Open Datasheet subform based on ID from main form

MattioMatt

Registered User.
Local time
Today, 03:24
Joined
Apr 25, 2017
Messages
99
Is it possible to open a pop up form that contains a datasheet subform and link the datasheet to only show records from the ID on the main form.

Button on main form opens a pop up form based on the AssetID from the main form in a list.
Currently I'm using a link criteria from the dynamic search on these forums, I'd like to use the selection (Asset ID) to then open a form that contains a subform datasheet with the Asset ID as a column but just show the records for that particular AssetID.

Is it possible to modify the below to do that?

Code:
    If IsNull(Me.SearchResults) Then
     MsgBox "Please select a record from the list to view", vbCritical
    Else
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmVulnRecords"
    
    stLinkCriteria = "[AssetID]=" & Me![SearchResults]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End If
 
Maybe I misunderstand you, but why not use the control name for the AssetID in the main form.
Code:
DoCmd.OpenForm stDocName, , , "[AssetID]=" & Me.[ControlNameForAssetIDInMainForm]
 
Thank you! This has worked perfectly!
 

Users who are viewing this thread

Back
Top Bottom