Results 1 to 5 of 5
  1. #1
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37

    how to open another access database

    hye all...



    i want to ask is there any way to open another access database using when click button at form..
    for example i have tracking.accb then at my switchboard form, i would like to have a button that can go to another access which is borrow.accb.

    can these possible for me to do it..?
    any help much appreciate..

    thank in advance

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Google: VBA open Access file
    http://www.pcreview.co.uk/forums/wha...-t3889030.html

    Example:

    'following will now open the Access file
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run """C:\Program Files\Microsoft Office\Office12\msaccess.exe"" ""c:\MaterialsDatabase.accdb"""
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37
    thank June7 for reply..

    that meant i need to paste this code into the module right..

    Option Compare Database
    Option Explicit

    Private Declare Function apiShellExecute _
    Lib "shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long


    Public Function ShellEx(FileName As String) As Boolean
    ShellEx = Iif( _
    apiShellExecute(0, "open", FileName, vbNullString, vbNullString, 1), _
    > 32, True, False

    End Function

    but then, where i need to paste your code?
    following will now open the Access file
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run """C:\Program Files\Microsoft Office\Office12\msaccess.exe"" ""c:\MaterialsDatabase.accdb"""

    thank in advance.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The sample code I provided does NOT need the apiShellExecute code. Those are two different methods to achieve the same end. The hyperlink method is a third.

    My example code can go in any procedure you want and is an example for the second method alluded to in the referenced link.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37
    owh yeah..

    thank you June7..it work great now..


Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open Access Database in Read Only Mode
    By praloy in forum Programming
    Replies: 2
    Last Post: 03-28-2012, 10:50 PM
  2. Replies: 7
    Last Post: 09-08-2011, 09:20 AM
  3. Access database won't open directly
    By Rale in forum Access
    Replies: 0
    Last Post: 03-24-2011, 03:33 AM
  4. Replies: 6
    Last Post: 11-18-2010, 04:00 AM
  5. What Database is Open? (Access 2007)
    By jhrBanker in forum Access
    Replies: 3
    Last Post: 06-06-2009, 09:00 AM

Tags for this Thread

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