Hi All,
This is driving me nuts!!
I have a form with a combo box that populates a subform with data equal to the combo box value. I have added "<ALL>" to the combo box to display all records if selected. The after update code changes the queryDefs. The problem I have is that when "<ALL>" is selected, no records show. But the query has updated. If I close the main form and reopen it all the records show, but if I select a new value nothing happpens. But the actual query has updated. I have tried many combinations of refresh, repaint...etc.
Anyway, here is the code, any help appreciated.
Private Sub cboFeedMtrl_AfterUpdate()
Dim qryAllMat As QueryDef
Dim sql As String
Set dbsCurrent = CurrentDb
Set qryAllMat = dbsCurrent.QueryDefs("qryViewData")
If Me![cboFeedMtrl].Value = "<ALL>" Then
qryAllMat.sql = "SELECT * FROM tblMachineSelection"
Me![frmViewData].Requery
Else
qryAllMat.sql = "SELECT * FROM tblMachineSelection where [feed Material] = [Forms]![frmView]![cboFeedMtrl]"
Me![frmViewData].Requery
End If
End Sub
This is driving me nuts!!
I have a form with a combo box that populates a subform with data equal to the combo box value. I have added "<ALL>" to the combo box to display all records if selected. The after update code changes the queryDefs. The problem I have is that when "<ALL>" is selected, no records show. But the query has updated. If I close the main form and reopen it all the records show, but if I select a new value nothing happpens. But the actual query has updated. I have tried many combinations of refresh, repaint...etc.
Anyway, here is the code, any help appreciated.
Private Sub cboFeedMtrl_AfterUpdate()
Dim qryAllMat As QueryDef
Dim sql As String
Set dbsCurrent = CurrentDb
Set qryAllMat = dbsCurrent.QueryDefs("qryViewData")
If Me![cboFeedMtrl].Value = "<ALL>" Then
qryAllMat.sql = "SELECT * FROM tblMachineSelection"
Me![frmViewData].Requery
Else
qryAllMat.sql = "SELECT * FROM tblMachineSelection where [feed Material] = [Forms]![frmView]![cboFeedMtrl]"
Me![frmViewData].Requery
End If
End Sub