Option group - Filter

TravelingCat

Registered User.
Local time
Today, 18:51
Joined
Feb 22, 2010
Messages
42
Ok, i have yet another question...
I have a main form, frmEvent, and a subform inside it, frmAssignments.
On the subform i have an option group, which is supposed to filter the assignments by type. Here's the code:

Code:
Private Sub FrameFilterAssignTypes_AfterUpdate()
globFilt = "assignType in " & IIf(FrameFilterAssignTypes = 1, "(1,2,3)", IIf(FrameFilterAssignTypes = 2, "(1)", IIf(FrameFilterAssignTypes = 3, "(2)", "(3)")))
Filter = globFilt
FilterOn = True
End Sub

globFilt is a global variable. Subform's allow edits is set to Yes now.
Debug stops on the red line and gives me "You canceled the previous operation".
The exact same code (with another names) worked great on the main form, so i'm guessing it has to do with option group being on the subform.
Please enlighten me, what is wrong here...
Thanks
 
Use If instead of IIF, I think IIF is for use in queries etc and IF is VBA.
 
Oh and try putting me. in front of filter and filteron.
 
Sorry ignore the first one - I wasn't aware that you could do it like that, I thought if's had to be if...then....else in VBA.

As an aside I'd use a select case statement for option groups, personally.
 
Thanks for your reply James,
Me. i tried that, doesn't change anything
I don't think that the code is the problem, since it works fine when it's on the main form.. but i tried it anyway, here's the beginning:
Code:
Select Case FrameFilterAssignTypes
Case 1:
[COLOR=red]Filter = "assignType in (1,2,3)"[/COLOR]
FilterOn = True
......
The red line is the one that gets the error, the same one
Any more ideas?
 
That error message, I think, means a typo in the code.

The only other thing I can think of is that Access doesn't like brackets in strings like that, but as you've said it works on the main form, I'm a wee bit stuck. Sorry!
 
Thanks for all your answers, but i hurry to inform you that my problem is solved.
The problem was that i'm a ***.. :) I totally forgot that "assignType" is a text field...
although the error message was a bit odd. As soon as i put ' ' around numbers of assignType, it worked fine
 

Users who are viewing this thread

Back
Top Bottom