Results 1 to 6 of 6
  1. #1
    cherold is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    82

    I get an error the first time I run an event call but not after that; is there a workaround?

    I have a form with two subforms. I change some properties of subforms with data from subform1, using subform1's OnCurrent event . So everytime the user changes rows in subform1, it will do this:



    Code:
    Forms("Song Collection Entry").subform2.Form.Member.DefaultValue = Me.[SongID].Value
    When I open the form, this causes an error message: Run-time error "2455": You entered an expression that has an invalid reference to the property Form/Report.

    However, after I click "End" on the error message, it works just fine.

    My guess is this is an issue with subform2 not being loaded the first time it's called.

    Right now I'm using a very cludgy workaround; I declare a global boolean, so the first time OnCurrent is called I check it, it's false, I skip the code and set it to true, and there are no errors.

    But I really hate to do something that sloppy. Is there a better workaround? A way to check whether Forms("Song Collection Entry").subform2.Form.Member exists or is initialized or whatever? Is there a way to check whether the subform is loaded? Or would I have to do something with error checking?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you dont need to set the subform default value if you have the subform bound on the LINK CHILD FIELDS, LINK MASTER FIELDS.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It is not clear to me how the forms are related.
    Do you have a Main form that has 2 sub forms at the same level
    Main form
    Sub Form1 | sub form2


    or a Main form with a sub form that has a sub form embedded in it?
    Main form
    --Sub Form1
    ---- sub form2



    You might look at Refer to Form and Subform properties and controls

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Hardly matters how they're related I'd say, because a subform opens and loads before the main form. I'm betting that its Current event will also fire before the main form even opens, thus a reference to a main form from a subform open/load/current event is of no use.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    cherold is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    82
    The first one:
    Main form
    Sub Form1 | sub form2


    Quote Originally Posted by ssanfu View Post
    It is not clear to me how the forms are related.
    Do you have a Main form that has 2 sub forms at the same level
    Main form
    Sub Form1 | sub form2


    or a Main form with a sub form that has a sub form embedded in it?
    Main form
    --Sub Form1
    ---- sub form2



    You might look at Refer to Form and Subform properties and controls

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Where I was headed was to use the main form Load event (maybe with some delays) to set the subform2 control default property.
    When I set a control's default property, I usually think of something like today's date or a state abbreviation. I don't know your naming convention, but it looks like you are putting a song id into a Member field???.


    What about using the subform2 before update event to insert the songID from subform1 into the control?

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

Similar Threads

  1. Append error statement workaround
    By Roncc in forum Access
    Replies: 6
    Last Post: 01-17-2018, 01:20 PM
  2. Replies: 1
    Last Post: 01-13-2015, 01:33 PM
  3. "Run Time Error 3146, ODBC call failed" :(
    By selvakumar.arc in forum Access
    Replies: 0
    Last Post: 12-04-2014, 01:57 PM
  4. Replies: 9
    Last Post: 12-08-2012, 04:56 PM
  5. How to call After update event to the textbox
    By pwalter83 in forum Forms
    Replies: 1
    Last Post: 12-20-2011, 11:16 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