Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / December 2006

Tip: Looking for answers? Try searching our database.

changing source object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
benj - 11 Dec 2006 05:25 GMT
I have created a main report with multiple possible subreports.  I placed an
unbound subreport in the main form with ON OPEN code:
Private Sub Report_Open(Cancel As Integer)
dim strSUBREP as string

if [Forms]![FM_MAIN]![age] = "Yes" then
 strSUBREP = "subreport1"
else
 strSUBREP = "subreport2"
end if
Me.subreport = strSUBREP
exit sub

Am getting the error 2450: can't find 'FM_MAIN' refered to in a VB code.
FM_MAIN is the main form where the field age is located.  I have tried using
Forms!FM_MAIN.age but still of no use.  What should i do?  Thanks in advance!
Allen Browne - 11 Dec 2006 07:32 GMT
Presumably fm_main is a form (not a report)?

Is the form open (not in design view) at the time?

Try changing the SourceObject property of the subreport control. That may
still not work, since Access opens the subreport *before* the main reports.

Signature

Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have created a main report with multiple possible subreports.  I placed
>an
[quoted text clipped - 15 lines]
> Forms!FM_MAIN.age but still of no use.  What should i do?  Thanks in
> advance!
benj - 12 Dec 2006 05:30 GMT
Thanks Allen!
FM_MAIN is a form and it was open (not in design view) when the preview icon
was clicked.  The preview icon is located in FM_MAIN.  What do you mean by
changing the Source Object property of the subreport control? I tried placing
and removing a source object, while the other property are more on the FORMAT.

> Presumably fm_main is a form (not a report)?
>
[quoted text clipped - 22 lines]
> > Forms!FM_MAIN.age but still of no use.  What should i do?  Thanks in
> > advance!
Allen Browne - 12 Dec 2006 06:25 GMT
No, I don't think that will work.

Perhaps you could place the various subreports on the main report, and then
toggle their Visible property so as to show or hide them, e.g.:

   If [Forms]![FM_MAIN]![age] = "Yes" Then
       Me.[Sub1].Visible = True
   Else
       Me.[Sub1].Visible = False
   End If

BTW, if age is a yes/no field, you will need:
   If [Forms]![FM_MAIN]![age] = True Then

We don't know what you are aiming to do, so it's not clear if that's the
best approach, or whether you would be better to create different reports
and call them depending on the values in the form.

Signature

Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Thanks Allen!
> FM_MAIN is a form and it was open (not in design view) when the preview
[quoted text clipped - 34 lines]
>> > Forms!FM_MAIN.age but still of no use.  What should i do?  Thanks in
>> > advance!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.