B
Brennan
I have a form that uses the DSUM function to pull information from a master
table. Right now, I am using the DSUM because have about 40 textboxes with
the DSUM as a control source because they all pull and sort data from the
same table. I am open to using SQL to populate the textboxes, but that is a
lot of rework. Anyhow, I am adding more criteria to the form to drill deeper
into the data and I need to know if you can create a stored variable and use
that variable in the DSUM equation. For example, I would like to change the
field that is used as a criteria in the DSUM function. Here is an example of
what I am doing and the VBA I have in to cause it to function.
DSUM function
=Val(nz(DSum("[sumofNet Amount - US]","POSTSALECOSTv1","[FML Account Code *]
= 4435 and crit = crit2 and [Accounting Period *]=" & [AccountingPeriod] &
""),0))
VBA
Private Sub Combo119_AfterUpdate()
Dim crit, crit1 As String
Me.Rank = Me.Combo119.Value
If Me.Rank = 1 Then Me.Criteria = "Region"
If Me.Rank = 1 Then Me.criteria2 = Me.Combo119.column(1)
If Me.Rank = 2 Then Me.Criteria = "Industry"
If Me.Rank = 2 Then Me.criteria2 = Me.Combo119.column(2)
If Me.Rank = 3 Then Me.Criteria = "Level 1"
If Me.Rank = 3 Then Me.criteria2 = Me.Combo119.column(3)
If Me.Rank = 4 Then Me.Criteria = "Level 2"
If Me.Rank = 4 Then Me.criteria2 = Me.Combo119.column(4)
If Me.Rank = 5 Then Me.Criteria = "Level 3"
If Me.Rank = 5 Then Me.criteria2 = Me.Combo119.column(5)
crit = Me.Criteria.Value
crit1 = Me.criteria2.Value
AS you can see, I am using the Combobox to determine which fields need to be
used as criteria and the value that should be used as the criteria for that
field. I then store those values in a textbox and then to a variable. I
welcome any suggestions. Thanks
Brennan
table. Right now, I am using the DSUM because have about 40 textboxes with
the DSUM as a control source because they all pull and sort data from the
same table. I am open to using SQL to populate the textboxes, but that is a
lot of rework. Anyhow, I am adding more criteria to the form to drill deeper
into the data and I need to know if you can create a stored variable and use
that variable in the DSUM equation. For example, I would like to change the
field that is used as a criteria in the DSUM function. Here is an example of
what I am doing and the VBA I have in to cause it to function.
DSUM function
=Val(nz(DSum("[sumofNet Amount - US]","POSTSALECOSTv1","[FML Account Code *]
= 4435 and crit = crit2 and [Accounting Period *]=" & [AccountingPeriod] &
""),0))
VBA
Private Sub Combo119_AfterUpdate()
Dim crit, crit1 As String
Me.Rank = Me.Combo119.Value
If Me.Rank = 1 Then Me.Criteria = "Region"
If Me.Rank = 1 Then Me.criteria2 = Me.Combo119.column(1)
If Me.Rank = 2 Then Me.Criteria = "Industry"
If Me.Rank = 2 Then Me.criteria2 = Me.Combo119.column(2)
If Me.Rank = 3 Then Me.Criteria = "Level 1"
If Me.Rank = 3 Then Me.criteria2 = Me.Combo119.column(3)
If Me.Rank = 4 Then Me.Criteria = "Level 2"
If Me.Rank = 4 Then Me.criteria2 = Me.Combo119.column(4)
If Me.Rank = 5 Then Me.Criteria = "Level 3"
If Me.Rank = 5 Then Me.criteria2 = Me.Combo119.column(5)
crit = Me.Criteria.Value
crit1 = Me.criteria2.Value
AS you can see, I am using the Combobox to determine which fields need to be
used as criteria and the value that should be used as the criteria for that
field. I then store those values in a textbox and then to a variable. I
welcome any suggestions. Thanks
Brennan