Results 1 to 3 of 3

Thread: A basic Access question about calling a sub from a button

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Posts
    138

    A basic Access question about calling a sub from a button

    Hi all!
    I have this form on which lies a button that calls another form. Very simply, in the On Open event of this button, I call a sub that will open the form, as follow:

    =Open("frmMyForm")

    Now the code read something like this:

    Function Open(MyForm As string) As Integer

    Select Case MyForm
    Case "frmMyForm"
    DoCmd.OpenForm MyForm

    bla bla bla...

    Can I pass the form as an object instead of a string? If so what do I have to change in the above?
    I tried (and tons of variations):

    =Open(frmMyForm)

    Function Open(MyForm as object)

    with no obvious result.

    Anyone's two cents would be appreciated.

    p.s. Access 2000

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

    Re: A basic Access question about calling a sub from a button

    Seems like your going about this the long way? If you pass the Form as a Form then there is no need for a select case statement. Just
    the call to open the form.

    DoCmd.OpenForm "MyForm"
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Posts
    138

    Re: A basic Access question about calling a sub from a button

    Hi there Rob,

    I was really looking into how to pass diff. arguments type to a sub using the OnEvent property, beside from string type as in =MySub("frmname") ,well if it is possible.

    I presume I went asking about this the wrong way. I couldn't care less about opening a form.
    lol

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