Good Afternoon Everyone,
I’m certain there is a way to do this, but I just don’t know how.
I have an unbound subform. The recordset to this subform is created on the fly depending on selections made by the user. All works well.
The recordset(rs) has 8 fields and are:
DxCode
Primary_DxDescription–this is the primary diagnosis description field such as Depression
Member_ID
Member_Name
DOB
Age
Gender
RiskScore
I will be adding a “Sub_DxDescription” field to the rs. This will house the sub categories to the Primary_DxDescription, such as Manic, Phych, etc. It will provide grouping of the Primary_DxDescription data.
What I want to do is let the user HIGHLIGHT a range of data in the rs based on the Sub_DxDescription and export that data to Excel (see example attachment).
I already have the code that creates the records source, I have the code that exports the data to Excel, what I don’t have is the ability to create a new rs using the RECORDS SELECTED by the user from the original rs. Can this be done, and if so, any ideas on how?
I thought about changing the subform to a list box and modifying the following code but just can’t get a grasp on it.
Dim ctl As Control Dim varItem As Variant Dim sTemp As String Set ctl = Me.ListBoxName For Each varItem In ctl.ItemsSelected Add to a tblDef or create a SQL statement and add it to the SQL statement. sTemp = sTemp & ctl.ItemData(varItem) & ", " Next varItem If sTemp = "" Then Else 'Remove the last comma and space sTemp = Left$(sTemp, Len(sTemp) - 2) End If