JamesMcS
Keyboard-Chair Interface
- Local time
- Today, 12:50
- Joined
- Sep 7, 2009
- Messages
- 1,819
Hi! Right, I'm not even sure if this is the way to go with this one, let me explain:
I've got a table with manufacturers, countries, and sales for that country. The form is based on this table and is showing all manufacturers, countries and sales absolutely fine.
Now, I've added 12 checkboxes to the header of the form, one for each of the 12 countries, all true by default. What I want to do is have these checkboxes alter the form filter string depending on which ones are selected, but still have the filter string make sense....
Each of the check boxes is called "Org_Box1", "Org_Box2"... up to 12.
In the afterupdate of each box, I'm calling a function. The function contains an array of the 12 countries, whose position in the array matches up to the name of its check box on the form - so Org_Box1 is GB, and the first entry in the array is GB. Here's the code I've got so far:
What I'm trying to get it to do is pull back the name of the check box on the form, but from a variable (chkboxvar), so when counter_val is 1, chkboxvar contains "[Org_Box1]", referring to the check box on the form. If the box is checked, I want it to add "GB01" into the filter string (GB01 being the first entry in the array Org_Array, of course). Clever, I thought, but I get type mismatch - obviously because it's trying to evaluate a string to a true/false.
I should also mention that when it hangs on the if line, the varaiable chkboxvar does indeed contain the value "[Org_Box1]".
Any ideas on how I can get around this, or is there a method for doing this that I haven't thought of? Probably....
I've got a table with manufacturers, countries, and sales for that country. The form is based on this table and is showing all manufacturers, countries and sales absolutely fine.
Now, I've added 12 checkboxes to the header of the form, one for each of the 12 countries, all true by default. What I want to do is have these checkboxes alter the form filter string depending on which ones are selected, but still have the filter string make sense....
Each of the check boxes is called "Org_Box1", "Org_Box2"... up to 12.
In the afterupdate of each box, I'm calling a function. The function contains an array of the 12 countries, whose position in the array matches up to the name of its check box on the form - so Org_Box1 is GB, and the first entry in the array is GB. Here's the code I've got so far:
Code:
Public Sub R24_Org_Filter()
Dim Org_Array As Variant, Counter_Val As Integer, Filter_String As String, Chkboxvar As String
Org_Array = Array("'GB01'", "'FR01'", "'DE01'", "'IT01'", "'AT01'", "'BE01'", "'DK01'", "'ES01'", "'IE01'", "'NL01'", "'NO01'", "'SE01'")
Filter_String = "[Salesorg]="
Counter_Val = 1
Chkboxvar = "[Org_Box" & Counter_Val & "]"
Do While Counter_Val < 13
[B] [COLOR=red] If Chkboxvar = True Then[/COLOR][/B]
Filter_String = Filter_String & Org_Array(Counter_Val) & " OR "
End If
Counter_Val = Counter_Val + 1
Loop
Forms![Mfr R24 Subform].Filter = Filter_String
Forms![Mfr R24 Subform].FilterOn = True
End Sub
What I'm trying to get it to do is pull back the name of the check box on the form, but from a variable (chkboxvar), so when counter_val is 1, chkboxvar contains "[Org_Box1]", referring to the check box on the form. If the box is checked, I want it to add "GB01" into the filter string (GB01 being the first entry in the array Org_Array, of course). Clever, I thought, but I get type mismatch - obviously because it's trying to evaluate a string to a true/false.
I should also mention that when it hangs on the if line, the varaiable chkboxvar does indeed contain the value "[Org_Box1]".
Any ideas on how I can get around this, or is there a method for doing this that I haven't thought of? Probably....
Last edited: