Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86

    Angry Unanswered: Help opening another db in code

    i have an access97 db, within the code i am trying to open another access97 db and close the first one. this is the code i was using, but as soon as it reaches the end sub, both db's close. please help

    Private Sub Form_Timer()
    Dim accApp As Access.Application
    Dim stDocName As String
    Dim CloseTime As Date
    CloseTime = "16:00:00"
    DoCmd.SetWarnings False

    stDocName = "qry-UpdateRemoveUsersTime"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    stDocName = "frm-RemoveUserError"

    Child47.Requery

    If RemoveUsers.Value = 0 Then DoCmd.OpenForm stDocName: Exit_Click Else
    If UserName.Value = "UsersName" Then
    If Now >= CloseTime Then
    ' Me.TimerInterval = 0

    ButtonTest.FontBold = False

    Set accApp = CreateObject("Access.Application")
    accApp.Visible = True
    accApp.OpenCurrentDatabase "C:\N Drive\EH Database\Electra House Database (Maintenance).mdb", True
    'accApp.DoCmd.OpenForm "frm-Maintenance"
    Exit_Click
    End If
    End If

    End Sub

  2. #2
    Join Date
    Nov 2003
    Location
    Warren, PA
    Posts
    52
    Quote Originally Posted by Mowgli212001
    i have an access97 db, within the code i am trying to open another access97 db and close the first one. this is the code i was using, but as soon as it reaches the end sub, both db's close. please help

    Private Sub Form_Timer()
    Dim accApp As Access.Application
    Dim stDocName As String
    Dim CloseTime As Date
    CloseTime = "16:00:00"
    DoCmd.SetWarnings False

    stDocName = "qry-UpdateRemoveUsersTime"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    stDocName = "frm-RemoveUserError"

    Child47.Requery

    If RemoveUsers.Value = 0 Then DoCmd.OpenForm stDocName: Exit_Click Else
    If UserName.Value = "UsersName" Then
    If Now >= CloseTime Then
    ' Me.TimerInterval = 0

    ButtonTest.FontBold = False

    Set accApp = CreateObject("Access.Application")
    accApp.Visible = True
    accApp.OpenCurrentDatabase "C:\N Drive\EH Database\Electra House Database (Maintenance).mdb", True
    'accApp.DoCmd.OpenForm "frm-Maintenance"
    Exit_Click
    End If
    End If

    End Sub
    Call Shell("C:\Program Files\Microsoft Office\Office10\msaccess.exe Y:\DATABASEPATH\DBNAME.mdb",1) ' opens new database
    DoCmd.Quit acSave 'close current DB

    bhummel

  3. #3
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86
    cheers Bhummel. but it's coming up with the following error.

    The command line you used to start Microsoft Access contains an option that Microsoft Access doesn't recognize

    Exit and restart Microsoft Access using valid command-line option.

    this is code i used
    Call Shell("C:\Program Files\Microsoft Office\Office\msaccess.exe C:\N Drive\EH Database\Electra House Database (Maintenance).mdb/excl ", vbMaximizedFocus) ' opens new database

Posting Permissions

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