Results 1 to 5 of 5
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    chaging a subreport's source object at runtime

    I have a report that, depending on..., wil require 1 of several different footers
    So, in the page footer, I've placed an unbound subreport (child283) (to be remnamed later...)
    and have added this code (as a starting point in the Report,s load event)

    srptAB = InputBox("A or B?")
    If srptAB = "A" Then
    Me.Child283.SourceObject = "srpt_FOOTA"
    Else
    Me.Child283.SourceObject = "srpt_FOOTB"


    End If

    but am getting this error...
    '2191'
    "... can't set the Source Object property in the print preview or after printing has started" (?)


    Q.
    Am I even in the right direction ?

    With much appreciation in advance,
    Mark

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You need to determine If srptAB = "A" in the OnLoad or OnOpen event. You can create some DAO or do a Dlookup in the OnLoad or pass the value of srptAB to the report in the OpenArgs.

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    a bit confused..

    the above code is in the report's on_load event

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    What is srptAB? Is it a variable? How is it determined what the value of the variable is? Maybe you can create a recordset to query one or more of the tables to determine the value of your variable. In the OnLoad event, you can create a DAO object or sue a DLookup function to retrieve data from tables. The report's controls and or Recordsource is empty at the time of the Onload event.

    Certain Data will be available during certain OnFormat events. However, OnFormat will likely be too late for the assignment of a subquery.

  5. #5
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    sorry for the late follow-up

    determining the value of srptAB was not an issue (all of that code hadn't yet been written, but was to be...)
    the problem's solution turned out to be very simple:

    the the Source Object for a subReport needs to be changed in the parent report's OnOpen event; attempting to do so in the OnLoad event (as I had been) was too late...

    problem solved (thnx for all the insight),
    Mark

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 10-23-2015, 05:23 PM
  2. Runtime 424 error... Object required.
    By sanderson in forum Programming
    Replies: 8
    Last Post: 08-09-2015, 08:10 PM
  3. Runtime Error 424 Object Required
    By Maltheo2005 in forum Programming
    Replies: 9
    Last Post: 06-13-2013, 04:52 PM
  4. Form with Subreport and setting record source.
    By Monterey_Manzer in forum Forms
    Replies: 3
    Last Post: 02-14-2013, 05:14 PM
  5. Replies: 13
    Last Post: 06-12-2012, 09:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums