Setting RecordSource off of Radio Buttons

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Let me start by saying I'm new to the programming aspect of Access. What I
would like to do is basically filter the view of records off of Radio
Buttons in the form footer. My thinking is that with Queries already
created, I could use Select Case to change the RecordSource property based
on with option is selected.

The code I've come up with is below. I keep getting an invalid use of
property compile error. Looking in help, all I can surmise is that the
RecordSource property is read-only.

Private Sub SelectView_AfterUpdate()
On Error GoTo SelectView_AfterUpdateErr

Select Case [SelectView]
Case 1
Set Forms![Member Form].RecordSource = "Member Query"
Case 2
Set Forms![Member Form].RecordSource = "Member Query (Board)"
Case 3
Set Forms![Member Form].RecordSource = "Member Query
(Volunteer)"
Case 4
Set Forms![Member Form].RecordSource = "Member Query (Vendor)"
End Select

Exit_SelectView_AfterUpdate
End Sub

SelectView_AfterUpdateErr
MsgBox Err.Description
Resume Exit_SelectView_AfterUpdate

End Sub

What is the best way to get this working??? Any help is greatly
appreciated.

Paul
 
The code I've come up with is below. I keep getting an invalid use of
property compile error. Looking in help, all I can surmise is that the
RecordSource property is read-only.

Even worse: it is a String type. The Set instruction applies to Object
types only. You need the (implicit) Let instruction.

So
Set Forms![Member Form].RecordSource = "Member Query" becomes
Forms![Member Form].RecordSource = "Member Query"

or, since I suspect the code runs from that form,
 
Drop the word "Set". That's only used for assigning objects.

If you prefer, you can also assign the query statement to the form:
Forms![Member Form].RecordSource = "SELECT * FROM [MemberTable] WHERE
MemberType = 'Board';"
 
Back
Top