I have a main form (frmMaintenance) with a subform (frmMaintenance_Subform).
The subform has only one unbound control (text box) that I want to use to display records from different tables. I have been able to set the data source of the subform using VBA (see code below)
Private Sub optValueLists_AfterUpdate()
Dim strInput As String
Select Case Me.optValueLists
Case 1
strInput = "vlStatus"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
Case 2
strInput = "vlPosition"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
Case 3
strInput = "vlDepartment"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
Case 4
strInput = "vlClass"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
End Select
End Sub
I know this works because I see the record count change in the subform. However, what I can't seem to do is set the record source for the unbound text box after VBA sets the record source for the subform.
I have attached an image of the form in the hope that it will give you an idea of what I am working with. Any suggestions would be greatly appreciated.
The subform has only one unbound control (text box) that I want to use to display records from different tables. I have been able to set the data source of the subform using VBA (see code below)
Private Sub optValueLists_AfterUpdate()
Dim strInput As String
Select Case Me.optValueLists
Case 1
strInput = "vlStatus"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
Case 2
strInput = "vlPosition"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
Case 3
strInput = "vlDepartment"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
Case 4
strInput = "vlClass"
Me.frmMaintenance_subform.Form.RecordSource = "Select * from " & strInput & ""
End Select
End Sub
I know this works because I see the record count change in the subform. However, what I can't seem to do is set the record source for the unbound text box after VBA sets the record source for the subform.
I have attached an image of the form in the hope that it will give you an idea of what I am working with. Any suggestions would be greatly appreciated.