By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,974 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,974 IT Pros & Developers. It's quick & easy.

Change Form Source Recordset Dynamically

P: n/a
I have a form that is used to display patient records. It's default
Recordset is set to a query which shows only current clients. I want
to use an option box on the form to force the form to use the client
table (tblClients) as it's source Recordset, which would display ALL
clients (past and present), not just current clients. How do I
accomplish this?
Jul 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ch***************@charter.net wrote:
I have a form that is used to display patient records. It's default
Recordset is set to a query which shows only current clients. I want
to use an option box on the form to force the form to use the client
table (tblClients) as it's source Recordset, which would display ALL
clients (past and present), not just current clients. How do I
accomplish this?
I might create an OptionGroup with 3 checkbox options; Current,
Archived, All in the form's FormHeader band. Give it a name like
FramePatients. Set the default to 1 which would be current patients.

Your form's recoursource should have no filter; a simple table or query
is all that is needed.

Then create a subroutine similar to the following.
Sub SetFilter()
Dim strF As String

Select Case Me.FramePatients
Case 1
'use your active status flag
strF = "ActivePatient = True"
Case 2
strF = "ActivePatient = False"
End Select

'since 3 is All, StrF will be ""
Me.Filter = strF
Me.FilterOn = (strF "")
End Sub

Now in the form's OnOpen event and the OnClick event of the Option group
enter
SetFilter
You'd open the form like this
Docmd.Openform "FormName"
without a filtering argument.

Pretty Wahine
http://www.youtube.com/watch?v=h9Wx63W_zBA
Jul 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.