I have a pop up search form that I use to find National level Contact names (located in a Main Form) that are connected to Local level Contact names (located in that Main Form's Subform). [This form pulls one or more National Names in connection with a Local name, as each local name could be entered under several national level records.]
[The regular system find mechanism doesn't work to search 'all' records for both main & subforms - so I created multiple mini-search forms for various needs.]
When the National level Contact search results are populated into the search form, I want users to be able to double click on the National level Contact name and return to the main form with that record in focus. Then they can go to the subform record if they want (I couldn't figure out how to take them to that exact subform record). While they use the pop up search form, the main form remains open with the pop up being a modal form on top.
I am using the OpenForm command on doubleclick event of the pop up form's search results field to do the following vba code:
Private Sub CTU_PI_Name_DblClick(Cancel As Integer)
On Error GoTo Err_CTU_PI_Name_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Main Admin Book Form" 'Main data entry form name
stLinkCriteria = "[CTU ID]=" & Me![CTU ID] 'go to the record where the primary key fields match
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CTU_PI_Name_Click:
Exit Sub
Err_CTU_PI_Name_Click:
MsgBox Err.Description
Resume Exit_CTU_PI_Name_Click
DoCmd.Close "CRS SL Search" 'close Pop up main form
End Sub
This code works well for filtering the form to just that record, but I don't want it 'filtered' as much as just having the selected record in focus.
I have read some on the openargs portion of the openform command, but I am not sure how to apply it to this situation as both forms are actually open.... I have also tried to play with DLookup. Worst case scenerio is to have a 'filter off' button on the main form that removes the search filter when staff are done with that specific record.
Any other ideas would be great!
Specific database/form info:
Main data entry form: Main Admin Book Form
Related subform: CRS Info subform
Main table: CTU Info (one side of rel. join)
Subform table: CRS Info (many side of rel. join)
Popup Form: CRS SL Search
Popup Form subform: CRS SL Search Results
Popup subform Field linked to event: CTU PI Name
Linked primary key fields at national level: CTU ID
Linked primary key fields at local level: CRS ID
[The regular system find mechanism doesn't work to search 'all' records for both main & subforms - so I created multiple mini-search forms for various needs.]
When the National level Contact search results are populated into the search form, I want users to be able to double click on the National level Contact name and return to the main form with that record in focus. Then they can go to the subform record if they want (I couldn't figure out how to take them to that exact subform record). While they use the pop up search form, the main form remains open with the pop up being a modal form on top.
I am using the OpenForm command on doubleclick event of the pop up form's search results field to do the following vba code:
Private Sub CTU_PI_Name_DblClick(Cancel As Integer)
On Error GoTo Err_CTU_PI_Name_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Main Admin Book Form" 'Main data entry form name
stLinkCriteria = "[CTU ID]=" & Me![CTU ID] 'go to the record where the primary key fields match
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CTU_PI_Name_Click:
Exit Sub
Err_CTU_PI_Name_Click:
MsgBox Err.Description
Resume Exit_CTU_PI_Name_Click
DoCmd.Close "CRS SL Search" 'close Pop up main form
End Sub
This code works well for filtering the form to just that record, but I don't want it 'filtered' as much as just having the selected record in focus.
I have read some on the openargs portion of the openform command, but I am not sure how to apply it to this situation as both forms are actually open.... I have also tried to play with DLookup. Worst case scenerio is to have a 'filter off' button on the main form that removes the search filter when staff are done with that specific record.
Any other ideas would be great!
Specific database/form info:
Main data entry form: Main Admin Book Form
Related subform: CRS Info subform
Main table: CTU Info (one side of rel. join)
Subform table: CRS Info (many side of rel. join)
Popup Form: CRS SL Search
Popup Form subform: CRS SL Search Results
Popup subform Field linked to event: CTU PI Name
Linked primary key fields at national level: CTU ID
Linked primary key fields at local level: CRS ID