Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33

    change a control from a subform or after openform command

    Hi
    How do I change a control from within a called subform? Or how do I return an argument to the calling form?

    Ive tried in the subform with »Me.Parent!control«, »Me!Parent!control«, »Forms!Formname!control«. Nothing worked.



    Then I tried getting the OpenArgs after the oppening with
    »DoCommand.OpenForm "ufSubform", OpenArgs:=Params«,
    but OpenArgs ist Null and Params contains only what it had before the open of the subform.

    Thanks for your help

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I don't understand what you are trying to do.

    Are you trying to display on the main form a value (perhaps a total?) which is on the sub form?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    yes. on the main form I have a label, which displays a text depending on a condition, which can be changed in the sub form.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Try something like:

    Parent.LabelName.Caption = "Text to be Shown"

    In the AfterUpdate event of the control on the sub form
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    This is the code:
    Parent.Freigabestatus.Caption = "soso"
    and it results in a runtime error 2452: The expression you entered has an invalid reference to the Parent property.

    I also tried Parent.Freigabestatus!Caption an other combinations of . !

    And I use in in the click Event of a command button, but I don't think that matters..

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    The error message is telling you that the form containing the control which is firing the code doesn't have a parent form. So, is the "subform" actually a subform control on the main form or is this "subform" just another form which was opened when the main form was opened.

    If it is a proper sub form, I would suspect that something is corrupt. Perhaps you could post a copy of the db.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    It is a sub form that opens with a command button.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by walterio View Post
    It is a sub form that opens with a command button.
    Then that is not a sub form.

    So, code would be something like:

    Forms!NameOfForm.LabelName.Caption = "Text to be Shown"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    runtime error 2450 MS A cannot finr the referenced form ...
    I'm calling this not-subform from a real sub form. May it be, that that is the problem?
    I tried another way: this not-subform is called with some arguments in OpenArgs, so I tried tu use the same wys back. But this doesn't work, OpenArgs is Null.

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by walterio View Post
    runtime error 2450 MS A cannot finr the referenced form ...
    I'm calling this not-subform from a real sub form. May it be, that that is the problem?
    I tried another way: this not-subform is called with some arguments in OpenArgs, so I tried tu use the same wys back. But this doesn't work, OpenArgs is Null.
    I don't understand.
    Please post a copy of the db
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    ok, give me some minutes.
    and by the way: thank you very much for your support.

  12. #12
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33

    Instead of a db

    I'm sorry, but the db is to big, although there is only 1 record in each File...
    So I'm attaching only the modules of the 3 forms involved:
    • ufAuftrags_Messungen, the sub Form which contains the command button involved in this drama
    • ufMessung_Freigabe and ufMessung_Freigegeben, the two called forms, depending on the field "Freigegeben", both permit the swich from one state to the other...


    Hope it's not "toooo much information!"
    Attached Files Attached Files

  13. #13
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    What do you think of my other approach: returning from the forms and thanks to an argument the settings for the Freigabestatus-Field could be defined. Only: how do I get the arguments from a called form?

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by walterio View Post
    I'm sorry, but the db is to big, although there is only 1 record in each File...
    So I'm attaching only the modules of the 3 forms involved:
    • ufAuftrags_Messungen, the sub Form which contains the command button involved in this drama
    • ufMessung_Freigabe and ufMessung_Freigegeben, the two called forms, depending on the field "Freigegeben", both permit the swich from one state to the other...


    Hope it's not "toooo much information!"
    "Compact and Repair" the db and then compact it to a "Zip" file before trying to attach the db.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    ok, but I have to postpone the matter for tomorrow? Thank you for your help, so far.

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. subform openform
    By slimjen in forum Forms
    Replies: 4
    Last Post: 06-21-2019, 11:31 AM
  2. Replies: 11
    Last Post: 08-22-2017, 05:50 PM
  3. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  4. Replies: 3
    Last Post: 10-07-2013, 12:27 PM
  5. Replies: 2
    Last Post: 12-17-2010, 11:12 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