Results 1 to 3 of 3

Thread: [2005] Form Status...

  1. #1

    Thread Starter
    Addicted Member phenom's Avatar
    Join Date
    Apr 2006
    Location
    UAE
    Posts
    233

    Exclamation [2005] Form Status...

    Dear All,
    Can anyone tell me how can I run a function or a sub from one form to another?

    Let say I have a form that allow the user to enter information of an employee, (first, Last name, Add, and Department name etc…) the department name is a Combo box, that contain all the names of Department, if the user want to add new department he can press a button which load the Department form (different form). What I want is, when the user enters the new department and the User info form is loading, I want the Department list (combo box) in the (user form) to refresh and get the new list name of Department. “How can I do it?” I hope that I made it clear…

    Appreciate any help…

    Regards,
    =======================================
    If I helped you, Kindly Rate my post. Thanks
    -----------
    PHENOM

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Form Status...

    That's what data binding is for. You might have your Departments in a List(Of Department). You bind that List to your ComboBox. When you open the Departments dialogue and add a new Department you add it to that same List. You then call ResetBindings on the BindingSource and it will refresh the items displayed in the ComboBox from the List. It's this sort of thing that makes data-binding incredibly useful, despite some people's determination that it is inherently wrong (not you, someone else).
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Form Status...

    You can transer data between two forms by creating some properties on your first form so the second form can read and set it as needed. Then in your first form, when the second closes from being displayed with .ShowDialog, you can refresh the dataset that should be bound to your combo and read the forms property to see what was set from the popup form.
    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