Results 1 to 7 of 7

Thread: [RESOLVED] how to read SQL statement from my MDB?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Resolved [RESOLVED] how to read SQL statement from my MDB?

    hi, all!

    I have for example:
    Access DB without any password - DB1.MDB
    my Table - Table1
    my Query - Query1 = SELECT Table1.* FROM Table1;

    how can I read this string with SQL statement from my VB6-Project?

    thanks a lot in advance

    kind regards,
    Baloo.
    Last edited by Baloo; Feb 13th, 2006 at 12:46 PM.

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

    Re: how to read SQL statement from my MDB?

    Create a QueryDef object and open your "Query1" object. Set a reference to Access in your project and you will find the QueryDefs collection in the Object Browser.
    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
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Re: how to read SQL statement from my MDB?

    RobDog888, thanks a lot!
    But could you be so kind to show me a small code-example?

    kind regards,
    Baloo.

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: how to read SQL statement from my MDB?

    Quote Originally Posted by Baloo
    RobDog888, thanks a lot!
    But could you be so kind to show me a small code-example?

    kind regards,
    Baloo.
    IF you would have done a little bit search in the Forum you would have neded up with lots of samples. Take a look here
    http://www.vbforums.com/search.php?searchid=634483
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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

    Re: how to read SQL statement from my MDB?

    VB Code:
    1. Private Sub ReadQuery()
    2.     Dim qry As QueryDef
    3.     Set qry = Application.CurrentDb.QueryDefs("Query2")
    4.     MsgBox qry.SQL
    5.     qry.Close
    6. End Sub
    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

  6. #6
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: how to read SQL statement from my MDB?

    Or to shorten the code down

    VB Code:
    1. MsgBox CurrentDb.QueryDefs("Query1").SQL
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    Re: how to read SQL statement from my MDB?

    hi all!

    Its worked
    thanks to everyone for your attention

    kind regards,
    Baloo.

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