Results 1 to 4 of 4
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    Subreport wont hid field until I click on it

    I am using an if statemen in the onload event of a subreport to hide a field if it is a certain value. However, since the subreport doesn't have focus it doesnt hide the field until I click on it. I have tried to set the focus using

    Reports!rptCoverSheetInvoice!rptCoverSheetInvoice_ Customer.Form!CustomerName.SetFocus but it gives me runtime error 2467 The expression you entered refers to an object that is closed or doesnt exist.



    How can I get this vba code to work when the parent report is opened?

    Thanks

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    It should be .Report, not .Form?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    ok, after further googling I found the answer.

    First set focus to subform
    Then set focus to the control in the subform.

    Me.SubreportNameHere.SetFocus
    Me.SubreportNameHere!FieldYouWantToFocusOnHere.Set Focus

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You are mixing your objects - hard to tell which you are dealing with. A subform is a form. A subreport is a report. AFAIK, you cannot refer to .Form when the source object in the container (subform or subreport control) is a report.

    If I have a subreport in Child0 (the container/subreport control) this will give an error
    ?reports!rptsubtest.child0.Form.name

    This will return the name of the report
    ?reports!rptsubtest.child0.Report.name

    I see no need to set focus to a form (report??) before setting focus to a control on it.
    Moreover, you cannot hide a control that has the focus so I'm not seeing the point of setting focus to it anyway
    .

    I can hide a field on my report just with

    reports!rptSubTest.child0.report.[last Name].visible = false

    and nothing else.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 5
    Last Post: 05-11-2020, 01:13 AM
  2. Replies: 1
    Last Post: 01-10-2020, 05:56 PM
  3. Query wont show records with a blank field
    By bignate in forum Queries
    Replies: 2
    Last Post: 09-03-2013, 04:45 AM
  4. subreport wont filter
    By gregst in forum Reports
    Replies: 1
    Last Post: 05-30-2013, 10:38 AM
  5. Replies: 1
    Last Post: 04-15-2013, 10:02 AM

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