PC Review


Reply
Thread Tools Rate Thread

can you change the record source of a subform with a check box

 
 
hollyylloh
Guest
Posts: n/a
 
      20th Jun 2009
I have a form with a subform. I would like to allow the user to change the
record source of the subform by choosing a check box. I can do this with this
line of code:

Private Sub Loose_Click()
Forms!frmImportedIsLike![frmNewCompanyNameIsLike subform].Form.RecordSource
= "qryLoose"
end sub

However it only works with a simple query; one which uses only one table as
a source. As soon as i add a second table to the query the line of code above
quits working.

Is there another way to do this?

Thank you in advance.
 
Reply With Quote
 
 
 
 
David H
Guest
Posts: n/a
 
      20th Jun 2009
The number of tables should not impact changing the RecordSource. However,
you do have to ensure the field names in the queries match because the
controls point to specific fields.

I would actually go with adding a second subform and then use the .Visible
property to hide one and show the other. Another option would be to use the
tab control which allows would eliminate the need to add code to switch
between the two.

"hollyylloh" wrote:

> I have a form with a subform. I would like to allow the user to change the
> record source of the subform by choosing a check box. I can do this with this
> line of code:
>
> Private Sub Loose_Click()
> Forms!frmImportedIsLike![frmNewCompanyNameIsLike subform].Form.RecordSource
> = "qryLoose"
> end sub
>
> However it only works with a simple query; one which uses only one table as
> a source. As soon as i add a second table to the query the line of code above
> quits working.
>
> Is there another way to do this?
>
> Thank you in advance.

 
Reply With Quote
 
hollyylloh
Guest
Posts: n/a
 
      20th Jun 2009
Thank you, David, those sound like good ideas. I think the .visible option
makes much better sense than what I was trying to do, for what I need, thank
you.

"David H" wrote:

> The number of tables should not impact changing the RecordSource. However,
> you do have to ensure the field names in the queries match because the
> controls point to specific fields.
>
> I would actually go with adding a second subform and then use the .Visible
> property to hide one and show the other. Another option would be to use the
> tab control which allows would eliminate the need to add code to switch
> between the two.
>
> "hollyylloh" wrote:
>
> > I have a form with a subform. I would like to allow the user to change the
> > record source of the subform by choosing a check box. I can do this with this
> > line of code:
> >
> > Private Sub Loose_Click()
> > Forms!frmImportedIsLike![frmNewCompanyNameIsLike subform].Form.RecordSource
> > = "qryLoose"
> > end sub
> >
> > However it only works with a simple query; one which uses only one table as
> > a source. As soon as i add a second table to the query the line of code above
> > quits working.
> >
> > Is there another way to do this?
> >
> > Thank you in advance.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Syntax for subform record source change esn Microsoft Access Forms 6 12th Nov 2010 06:15 PM
Change record source of subform when click tab Steve Microsoft Access Form Coding 3 20th Jul 2008 06:51 AM
Change Subform within Subform record source proptery to paramter query sales@lunaraccents.com Microsoft Access Queries 2 30th Oct 2005 06:52 PM
Record Source for SubForm David F Microsoft Access Forms 1 7th Jun 2004 10:42 PM
change the record source of subform runtime 123 Microsoft Access Form Coding 2 14th Mar 2004 10:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.