Consulting

Results 1 to 12 of 12

Thread: Solved: Opening Files

  1. #1
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location

    Solved: Opening Files

    Hi,

    I have 2 questions both for VBA

    1. I w

  2. #2
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    I am pretty intuitive, but care to elaborate?
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  3. #3
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi Sorry,

    My explorer crashed i didn't think it posted.....

    I woud like to open an excel sheet inside excel and an access database from access,
    I have 2 buttons on my form one which should open an excel sheet and the other should open an access database as if i used windows explorer to open it.. hope that makes sense.....

    Thanks

    C19

  4. #4
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    No worries, welcome to the board!

    Okay...well, more information is needed.

    These buttons are on an excel form?

    To open an excel worksheet from excel...
    [vba]
    Workbooks.Add
    [/vba]

    Would add a new workbook to the instance of excel, and it would be default become the active workbook.

    [vba]

    Dim DPath As String
    DPath = "C:\Documents and Settings\Owner\My Documents\TEST.mdb"
    Set oApp = CreateObject("Access.Application")
    oApp.Visible = True
    oApp.OpenCurrentDatabase DPath
    [/vba]


    Would be a sample of opening Access from Excel, just specify the path to your database.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  5. #5
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi,

    Thanks,

    Both bits of code work great, thanks a lot for your hope really appreciated.

    C19

  6. #6
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi,

    I have added the code to an if statement but as soon as the if statement is has ended or the procedure ends the access closes?

    the code i am using is

    Dim ans As Boolean
    ans = MsgBox("Database Updated, would you like to open the database?", vbYesNo)
    If ans = True Then
    	Dim DPath As String
    	DPath = "S:\Hockney Folder Structure\CUSTOMER SERVICE\Michael\ACBS\ACBS.mdb"
    	Set oApp = CreateObject("Access.Application")
    	oApp.Visible = True
    	oApp.OpenCurrentDatabase DPath
    End If

  7. #7
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    YOu probably want to open a particular recordset or something right?

    DoCmd.OpenForm FormName

    or

    DoCmd.OpenTable "TableName"

    You can use that line to open a form in the access database...

    Since the excel code is opening the database, Excel is actually controlling the action. You can use the DoCmd line to open a query, table or other recordset... just change "FormName" to the form you want them to get to when..
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  8. #8
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi,

    I'd just like to display the tables once the database has opened, not any particular record or query etc...

    Thanks

    C19

  9. #9
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    [VBA]
    Dim DPath As String
    LPath = "C:\Documents and Settings\Owner\My Documents\db1.mdb"
    Set oApp = Access.Application
    oApp.Visible = True
    oApp.OpenCurrentDatabase LPath
    [/vba]

    This will keep it open. My code was more for gaining access to a recordset in access by creating an instance of it in the background.

    This keeps it open...
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  10. #10
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi,

    Thanks for that, will give it a try tomorrow and let you know how i get on.

    Thanks for the help BTW

    C19

  11. #11
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi,

    Do I need to add a reference for that bit of code? I am getting an object required error...

    Thanks

    C19

  12. #12
    VBAX Regular
    Joined
    Feb 2006
    Posts
    28
    Location
    Hi,

    All ok now, I needed a reference to the MS access object library.

    Access is now staying open ;-)

    Cheers

Posting Permissions

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