Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set of Access in Code

    What is the syntax to start a database (or for that matter a word doc or Excel sheet) from a command button click event?
    I have tried using the 'SHELL' command but it does not work.
    Any suggestions gratefully received

  2. #2
    carl g.
    Guest

    Re: Set of Access in Code

    fatherjack,

    In Access 97...

    Private Sub Command0_Click()
    On Error GoTo Err_Command0_Click

    Dim oApp As Object

    Set oApp = CreateObject("Excel.Application")
    oApp.Visible = True
    'Only XL 97 supports UserControl Property
    On Error Resume Next
    oApp.UserControl = True

    Exit_Command0_Click:
    Exit Sub

    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click

    End Sub

    I can't take any credit for this - it's actually created by one of the wizards that are installed on my Workstation that starts when the command button is created on a new form.

    Regards,

    Carl

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Set of Access in Code

    Are you trying to start the application and switch to it or just start it to use it from the current application?
    Charlotte

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set of Access in Code

    Carl's example is best (using the GetObject method), but you can start Access or whatever using Shell:


    Shell "start /w mydatabase.mdb"
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set off Access in Code

    I have written a VB6 application that will look for specific files and compare where the most uptodate version is - either on our network or on the users laptop. The app then allows the user to copy the newer version over the older. What i would like to do is put a button on the form to launch the database that is most up to date.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set off Access in Code

    the shell command with 'start' does it fine thank you.[img]/w3timages/icons/grin.gif[/img]
    I was not brought up on DOS so was not aware of the start command.[img]/w3timages/icons/baby.gif[/img]
    I just need to remember every time i use it to use 8.3 convention or it fails !!!![img]/w3timages/icons/doh.gif[/img]

Posting Permissions

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