Hello Everyone,
I am currently working on a form with multiple sub forms. Each sub form represent past forecasts with detail level, such as product type (ie box/bulk,etc).
I was wondering if there is any way to link all of the sub forms to the combo boxes
When a specific type of product is selected, I would like to be able to drill down to the customer level. Currently I am able to do so, only with the current month forecast, but no with the sales. Same happens if I tried to go to the Customer level (under Sales), I have to manually filter the info, as I can't seem to find a way to link the combo boxes to two or more sub-forms...
Below is my code related to my dilema:
Private Sub CmbAbbv_AfterUpdate()
Call SearchCriteria
Me.CboDescription.Requery
Me.cboplant.Requery
Me.CboShiptoName.Requery
End Sub
Private Sub CboDescription_AfterUpdate()
Call SearchCriteria
Me.cmbAbbv.Requery
Me.cboplant.Requery
Me.CboShiptoName.Requery
End Sub
Private Sub cboplant_AfterUpdate()
Call SearchCriteria
Me.cmbAbbv.Requery
Me.CboDescription.Requery
Me.CboShiptoName.Requery
End Sub
Private Sub CboShiptoName_AfterUpdate()
Call SearchCriteria
Me.cmbAbbv.Requery
Me.CboDescription.Requery
Me.cboplant.Requery
End Sub
Function SearchCriteria()
Dim Abbv, strDescription, strPlant, strShiptoName As String
Dim task, strCriteria As String
If IsNull(Me.cmbAbbv) Then
Abbv = "[Abbv] like '*'"
Else
Abbv = "[Abbv]='" & Me.cmbAbbv & "'"
End If
If IsNull(Me.CboDescription) Then
strDescription = "[Description] like '*'"
Else
strDescription = "[Description] = '" & Me.CboDescription & "'"
End If
If IsNull(Me.cboplant) Then
strPlant = "[Plant] like '*'"
Else
strPlant = "[Plant]= '" & Me.cboplant & "'"
End If
If IsNull(Me.CboShiptoName) Then
strShiptoName = "[SHIP_TO NAME] like '*'"
Else
strShiptoName = "[SHIP_TO NAME] = '" & Me.CboShiptoName & "'"
End If
strCriteria = Abbv & "And" & strDescription & "And" & strPlant & "And" & strShiptoName
task = "Select * from QryMarchFcst where " & strCriteria
Me.QryMarchFcst.Form.RecordSource = task
Me.QryMarchFcst.Form.Requery
End Function
Private Sub CboMaterial_AfterUpdate()
Me.cmbAbbv.Requery
Me.CboDescription.Requery
Me.cboplant.Requery
End Sub
Private Function ClearCtrl(Ctrl As Control)
Ctrl = Null
Call SearchCriteria
End Function
Private Sub CmdClearAll_Click()
Dim task As String
Me.cmbAbbv = Null
Me.CboDescription = Null
Me.cboplant = Null
Me.CboShiptoName = Null
task = "select * QryMarchFcst,QryDailySales where [Material] is null"
End Sub
Thanks a lot for your help!!!
I am currently working on a form with multiple sub forms. Each sub form represent past forecasts with detail level, such as product type (ie box/bulk,etc).
I was wondering if there is any way to link all of the sub forms to the combo boxes
When a specific type of product is selected, I would like to be able to drill down to the customer level. Currently I am able to do so, only with the current month forecast, but no with the sales. Same happens if I tried to go to the Customer level (under Sales), I have to manually filter the info, as I can't seem to find a way to link the combo boxes to two or more sub-forms...
Below is my code related to my dilema:
Private Sub CmbAbbv_AfterUpdate()
Call SearchCriteria
Me.CboDescription.Requery
Me.cboplant.Requery
Me.CboShiptoName.Requery
End Sub
Private Sub CboDescription_AfterUpdate()
Call SearchCriteria
Me.cmbAbbv.Requery
Me.cboplant.Requery
Me.CboShiptoName.Requery
End Sub
Private Sub cboplant_AfterUpdate()
Call SearchCriteria
Me.cmbAbbv.Requery
Me.CboDescription.Requery
Me.CboShiptoName.Requery
End Sub
Private Sub CboShiptoName_AfterUpdate()
Call SearchCriteria
Me.cmbAbbv.Requery
Me.CboDescription.Requery
Me.cboplant.Requery
End Sub
Function SearchCriteria()
Dim Abbv, strDescription, strPlant, strShiptoName As String
Dim task, strCriteria As String
If IsNull(Me.cmbAbbv) Then
Abbv = "[Abbv] like '*'"
Else
Abbv = "[Abbv]='" & Me.cmbAbbv & "'"
End If
If IsNull(Me.CboDescription) Then
strDescription = "[Description] like '*'"
Else
strDescription = "[Description] = '" & Me.CboDescription & "'"
End If
If IsNull(Me.cboplant) Then
strPlant = "[Plant] like '*'"
Else
strPlant = "[Plant]= '" & Me.cboplant & "'"
End If
If IsNull(Me.CboShiptoName) Then
strShiptoName = "[SHIP_TO NAME] like '*'"
Else
strShiptoName = "[SHIP_TO NAME] = '" & Me.CboShiptoName & "'"
End If
strCriteria = Abbv & "And" & strDescription & "And" & strPlant & "And" & strShiptoName
task = "Select * from QryMarchFcst where " & strCriteria
Me.QryMarchFcst.Form.RecordSource = task
Me.QryMarchFcst.Form.Requery
End Function
Private Sub CboMaterial_AfterUpdate()
Me.cmbAbbv.Requery
Me.CboDescription.Requery
Me.cboplant.Requery
End Sub
Private Function ClearCtrl(Ctrl As Control)
Ctrl = Null
Call SearchCriteria
End Function
Private Sub CmdClearAll_Click()
Dim task As String
Me.cmbAbbv = Null
Me.CboDescription = Null
Me.cboplant = Null
Me.CboShiptoName = Null
task = "select * QryMarchFcst,QryDailySales where [Material] is null"
End Sub
Thanks a lot for your help!!!