Results 1 to 6 of 6

Thread: Change object in another form?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    6

    Change object in another form?

    Hello there,

    In Access i have made several forms. But there is one form that stays on the foreground all the time, called frmGeopend. On that form i have a label, called lblInventarisatie. That label is invisible. Now i want that label to be visible as soon as i opened the form frmInventarisatie. And when i close lblInventarisatie the label on frmGeopend must be invisible again. I tried te follow code:

    frmInventarisatie:
    VB Code:
    1. Private Sub Form_Load()
    2. Form_frmGeopend.lblInventarisatie.visible = true
    3.  
    4. End Sub
    5.  
    6. Private Sub Form_unLoad()
    7. Form_rmGeopend.lblInventarisatie.visible = false

    Too bad that this code doesn't work

    does somenody know how to solve this problem.

    thanx

    Bubani

  2. #2
    New Member
    Join Date
    Sep 2003
    Location
    Germany
    Posts
    3
    Try this

    Code:
    Private Sub Form_Load()
    
      Forms(frmGeopend).lblInventarisatie.visible = true
    
    End Sub
    
    Private Sub From_Unload()
    
      Forms(frmGeopend).lblInventarisatie.visible = false
    
    End Sub

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Another syntax style...
    VB Code:
    1. Forms![frmGeopend]![lblInventarisatie].Visible
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    6

    Doesn't work

    Hey there thanks for your reply's but they still don't work.

    I tried this:

    VB Code:
    1. Forms![frmGeopend]![lblInventarisatie].Visible
    and this:
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.   Forms(frmGeopend).lblInventarisatie.visible = true
    4.  
    5. End Sub
    6.  
    7. Private Sub From_Unload()
    8.  
    9.   Forms(frmGeopend).lblInventarisatie.visible = false
    10.  
    11. End Sub

    but neither the 1st or the 2nd worked. I'm very sad about it, maybe there is another way to do this?
    Or could it be some settings?

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    The following code works fine for me, it may be that the event you're placing the code in isn't being fired.

    Create a new access database & create 2 forms.

    Form1 should have a button & a label, & the button should have this code:
    VB Code:
    1. Private Sub Command1_Click()
    2.     DoCmd.OpenForm "Form2"
    3.     Me.Label1.Visible = True
    4. End Sub

    Form2 should just be blank or have a standard label on. The form's code should contain this:
    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2.     Forms!Form1!Label1.Visible = False
    3. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    The order of operations for a form are:

    Loading:
    1.) Form_Open
    2.) Form_Load
    3.) Form_Resize
    4.) Form_Acitvate
    5.) Form_Current

    Unloading:
    1.) Form_Unload
    2.) Form_Close

    Maybe you may have some code in an event that fires after the
    Form_Load event changing the label visibility to false after you
    had changed it to true?

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width