FuzzyBear9
Technical User
Hi,
I am trying to write some VB code in Access 97. I want to filter information depending on the user's selection. I have successfully created an options group, but it does not account for two types of scenarios:
I have a two forms, one called frmSurvey and the other frmTracking. On frmSurvey I have a command button that opens frmTracking with a filter applied, showing only those records with a matching SurveyID.
My options group on frmTracking has two settings: 'All' or 'Chase'.
Chase selects only those records that have their 'to be chased' tickbox ticked. When I click on All, the form displays all records with matching SurveyID.
Here is my code:
Private Sub FilterOptions_AfterUpdate()
If FilterOptions = 1 Then
Me.Filter = "SurveyID = Forms!frmSurvey.SurveyID"
Me.FilterOn = True
ElseIf FilterOptions = 2 Then
Me.Filter = "Chase = Yes"
Me.FilterOn = True
End If
End Sub
If I open Tracking by itself, the form displays all records independent of the survey type. When I select 'Chase' from the options group, the form limits the records correctly.
PROBLEM:
When I try and select 'All' from the options group, Access returns the following error:
Enter Parameter Value Forms!frmSurvey.SurveyID
I realise the problem and have can get the options group to work when frmTracking is opened by itself:
Private Sub FilterOptions_AfterUpdate()
If FilterOptions = 1 Then
Me.FilterOn = False
ElseIf FilterOptions = 2 Then
Me.Filter = "Chase = Yes"
Me.FilterOn = True 'Apply the filter
End If
But I do not know how to COMBINE the TWO??? I want to be able to click the 'All' option and either limit the records to those that have a matching survey type or display all the records independent of survey type depending on how I opened frmTracking.
Any help would be greatly appreciated!!!
I am trying to write some VB code in Access 97. I want to filter information depending on the user's selection. I have successfully created an options group, but it does not account for two types of scenarios:
I have a two forms, one called frmSurvey and the other frmTracking. On frmSurvey I have a command button that opens frmTracking with a filter applied, showing only those records with a matching SurveyID.
My options group on frmTracking has two settings: 'All' or 'Chase'.
Chase selects only those records that have their 'to be chased' tickbox ticked. When I click on All, the form displays all records with matching SurveyID.
Here is my code:
Private Sub FilterOptions_AfterUpdate()
If FilterOptions = 1 Then
Me.Filter = "SurveyID = Forms!frmSurvey.SurveyID"
Me.FilterOn = True
ElseIf FilterOptions = 2 Then
Me.Filter = "Chase = Yes"
Me.FilterOn = True
End If
End Sub
If I open Tracking by itself, the form displays all records independent of the survey type. When I select 'Chase' from the options group, the form limits the records correctly.
PROBLEM:
When I try and select 'All' from the options group, Access returns the following error:
Enter Parameter Value Forms!frmSurvey.SurveyID
I realise the problem and have can get the options group to work when frmTracking is opened by itself:
Private Sub FilterOptions_AfterUpdate()
If FilterOptions = 1 Then
Me.FilterOn = False
ElseIf FilterOptions = 2 Then
Me.Filter = "Chase = Yes"
Me.FilterOn = True 'Apply the filter
End If
But I do not know how to COMBINE the TWO??? I want to be able to click the 'All' option and either limit the records to those that have a matching survey type or display all the records independent of survey type depending on how I opened frmTracking.
Any help would be greatly appreciated!!!