Results 1 to 8 of 8
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    syntax for subs

    ought to be easy... but this sort of stuff ALWAYS trips me (even with my "syntax for subs" cheat sheet)



    on my main report, i have a subReport: child_header
    my intent is to assign a value to a control on the subReport:

    * child_header is the container (control on the main report); the actual subReport within it is assigned in code.

    Code:
    with me
                  .Child_Header.SourceObject = "srpt_FixtSched_Header_Default"  '<-no error
               
                  ' and this is where the problem occurs.
                  ' ...tried every configuration that i can think of; yet am still unable to assign the caption to the control on the subReport
    
                 .Child_Header!Report.lblScheduleType.Caption = "CONTACT INFORMATION"
    as always, with appreciation in advance,
    mark

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Just guessing but based off this old thing maybe try this?
    Code:
    !Child_Header.Report!lblScheduleType.Caption = "CONTACT INFORMATION"

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Also try:
    Code:
    .Child_Header.Report.Controls("lblScheduleType").Caption = "CONTACT INFORMATION"
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I suspect there is an error - that would go a long way in trying to solve any issue??

    I also don't think it has anything to do with syntax, rather that the control doesn't actually contain the report because it's being assigned at runtime. It is a value for the .SourceObject property but doesn't exist in the physical design for the main report. If there is a way around this without opening the sub in design first, setting the caption, closing then assigning to the subreport control I don't know what that would be - aside from using a calculated textbox instead.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    or

    .Child_Header.Report.lblScheduleType.Caption = "CONTACT INFORMATION"

    don't think it is an issue with late binding the report to the subreport control as such - works with subforms which I do all the time. But reports do have different methodology and OP has not actually said what the problem is - syntax error, runtime error, caption not changed, whatever. For all we know, the label could be on a nested subreport

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    .Child_Header.Report.lblScheduleType.Caption = "CONTACT INFORMATION"
    Try that on a report where the subreport control has no sourceobject property in design but is set when the report is opened. You're using a different version so perhaps it works for you. None of the suggestions work for me. Can't even reference the name of the report that is assigned to the sourceObject property, as in

    Me.subContainerName.Report.Name
    or
    Reports!myReportName.subContainerName.Report.Name

    Punctuation (! vs .) does not matter. However, Me.subContainerName.SourceObject does return the property value that is assigned on report open. The error is always 2455: "you entered an expression that has an invalid reference to the property Form/Report. Not stating the actual problem or result or error number (with the message) in posts is a very frequent thing these days.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Well, I guess my problem was that to me, it's intuitive to set the sourceObject property OnOpen. Eventually I thought it was because I was opening in print preview but that turned out to not be the issue. However, I can access the .Report and a control on it in the Load event and it doesn't matter if it's print preview or not.
    Seems obvious now.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    BANG ! that did it...
    edited to read:

    Code:
    .Child_Header.Report.Controls("lblScheduleType").Caption = "CONTACT INFORMATION"
    and then moved the code into the OnLoad event (rather than OnOpen)

    It's all good now
    (and yes, you are correct: I should have posted the actual error #; apologies; should have known better)

    m.

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

Similar Threads

  1. Public Functions and Private Subs
    By d9pierce1 in forum Programming
    Replies: 15
    Last Post: 11-28-2018, 09:25 AM
  2. Why does code work on ertain subs but not on other?
    By Freddie81 in forum Programming
    Replies: 13
    Last Post: 05-24-2018, 08:49 AM
  3. Replies: 5
    Last Post: 01-08-2015, 12:40 PM
  4. Deleting unused subs
    By snipe in forum Programming
    Replies: 2
    Last Post: 12-20-2013, 01:57 PM
  5. Creating/Using Public Subs
    By sparlaman in forum Programming
    Replies: 3
    Last Post: 05-19-2011, 03:29 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