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

How to reference subform from a popup form

100+
P: 374
Hi all,

I am having some trouble, I am trying to create an advanced search form which will open up as a popup from my main search from.

I am using the Allen Browne method of creating the where string however I am setting the recordsource of the subform with a constructed sql string, not filtering.

My main form contains a subform which my basic search selects perfectly. However I cant seem to be able to get my advanced search to point down to the sub form correctly. I usually get the error "This object does not support this property or method" which keeps poping up everytime I close resulting in having to close access through task manager.

Below is the code I use to point to the record source of the main forms sub form:

Expand|Select|Wrap|Line Numbers
  1.     'Finally, apply the string as a query of the recordsource
  2.  
  3.     Dim topinsert2 As String
  4.  
  5.  
  6.     If comboNrecords2 = "All" Then
  7.  
  8.     topinsert2 = "All "
  9.  
  10.     Else
  11.  
  12.     topinsert2 = "TOP " & comboNrecords2 & " "
  13.  
  14.     End If
  15.  
  16.    Forms!frmlogforfiltering!subfrmlogforfiltering.RecordSource = "Select " & topinsert2 & " * FROM logforfiltering WHERE " & strwhere2
  17.  
my main form: frmlogforfiltering

my sub form: subfrmlogforfiltering

my advanced search form: frmAdvancedSearch


Thanks for any help,

Chris
Jul 28 '10 #1

✓ answered by MikeTheBike

@munkee
Hi

I think this may do it
Expand|Select|Wrap|Line Numbers
  1. Forms!frmlogforfiltering!subfrmlogforfiltering.Form.RecordSource = "Select " & topinsert2 & " * FROM logforfiltering WHERE " & strwhere
I believe (assume) that 'subfrmlogforfiltering' is the form's subform CONTROL, and not the subform itself. To access the subform's controls and properties you must refer to the Form object CONTAINED in the subform control.

It is confusing because Access gives the sub form control the same name as the sub form it contains by default (but you are given the opertunity to change it).

In later versions of Access 2003+ I prefer to use this form, not sure why, but probably because I never took thr trouble to understand Bangs(!)
Expand|Select|Wrap|Line Numbers
  1. Form_frmlogforfiltering.subfrmlogforfiltering.Form.RecordSource = "Select " & topinsert2 & " * FROM logforfiltering WHERE " & strwhere
Of course, this may not be the problem!

HTH


MTB

Share this Question
Share on Google+
1 Reply


Expert 100+
P: 636
@munkee
Hi

I think this may do it
Expand|Select|Wrap|Line Numbers
  1. Forms!frmlogforfiltering!subfrmlogforfiltering.Form.RecordSource = "Select " & topinsert2 & " * FROM logforfiltering WHERE " & strwhere
I believe (assume) that 'subfrmlogforfiltering' is the form's subform CONTROL, and not the subform itself. To access the subform's controls and properties you must refer to the Form object CONTAINED in the subform control.

It is confusing because Access gives the sub form control the same name as the sub form it contains by default (but you are given the opertunity to change it).

In later versions of Access 2003+ I prefer to use this form, not sure why, but probably because I never took thr trouble to understand Bangs(!)
Expand|Select|Wrap|Line Numbers
  1. Form_frmlogforfiltering.subfrmlogforfiltering.Form.RecordSource = "Select " & topinsert2 & " * FROM logforfiltering WHERE " & strwhere
Of course, this may not be the problem!

HTH


MTB
Jul 28 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.