Hey guys.. my turn to ask a question:
I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has no Master/Child relationship set to the main form. Specifically the problem seems to be that everytime the recordsource of the subform is changed, the subform object itself tries to set a default Master/Child value (both fields fill with the "ID" value). There is no real relationship between the forms, so it screws up the subform and the results are not correct.
I've found a workaround (lines 11 & 12), by clearing out the Master/Child values everytime I send a new recordsource, but it feels like a cheap work around and I'm wondering if there's something simple I've overlooked, or if this is a normal occurance.
Here's the code I'm using. This is called whenever the combo box on the main form has a value change, or when someone clicks the 'Reset' button next to it, which also set's the combo box's value to "All".
Main Form name: "Post-Submission QA"
combo box name: "cboDirecti on"
subform/subreport container name: "subPost_QA_Set _Mgmt"
subform name: "Post_QA_Set_Mg mt"
Again the above code works, but I'm wondering why it's behaving like this.. I'm also concerned that it may not work on a runtime client (which I have yet to test today).
I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has no Master/Child relationship set to the main form. Specifically the problem seems to be that everytime the recordsource of the subform is changed, the subform object itself tries to set a default Master/Child value (both fields fill with the "ID" value). There is no real relationship between the forms, so it screws up the subform and the results are not correct.
I've found a workaround (lines 11 & 12), by clearing out the Master/Child values everytime I send a new recordsource, but it feels like a cheap work around and I'm wondering if there's something simple I've overlooked, or if this is a normal occurance.
Here's the code I'm using. This is called whenever the combo box on the main form has a value change, or when someone clicks the 'Reset' button next to it, which also set's the combo box's value to "All".
Main Form name: "Post-Submission QA"
combo box name: "cboDirecti on"
subform/subreport container name: "subPost_QA_Set _Mgmt"
subform name: "Post_QA_Set_Mg mt"
Code:
Private Sub subfrmRequery()
If Me.cboDirection.Value = "All" Then
Forms("Post-Submission QA").Controls("subPost_QA_Set_Mgmt").Form.RecordSource = _
"SELECT * FROM [Post_QA_Set_Mgmt] ORDER BY [Post_QA_Set_Mgmt].[ID]; "
Else
Forms("Post-Submission QA").Controls("subPost_QA_Set_Mgmt").Form.RecordSource = _
"SELECT [Post_QA_Set_Mgmt].*, [Post_QA_Set_Mgmt].[Direction] as Filter FROM [Post_QA_Set_Mgmt] " & _
"WHERE ((([Post_QA_Set_Mgmt].[Direction])='" & Me.cboDirection.Value & "')) ORDER BY [Post_QA_Set_Mgmt].[ID]; "
End If
Me.subPost_QA_Set_Mgmt.LinkChildFields = ""
Me.subPost_QA_Set_Mgmt.LinkMasterFields = ""
Forms("Post-Submission QA").Controls("subPost_QA_Set_Mgmt").Form.Requery
End Sub
Comment