Results 1 to 11 of 11
  1. #1
    Said is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2018
    Location
    Alexandria, Egypt
    Posts
    6

    Access 2007 restarts itself after close

    Hi,

    I have Access 2007 running on Win 7 64 bit. My application consists of a back-end database which contains tables, forms, queries, and reports; and a front-end database which contains procedures and links to the back-end database' tables. The procedures call external 32 bit .dll subroutines and open the back-end database' tables, queries, and reports. The back-end database closes normally, while the front-end restarts itself twice with an unloaded database; once when closing the back-end database and another when closing itself. If closing the back-end database is deleted, the back-end database itself is restarted.

    Appreciated if there is a way to avoid Access restart. I tried with no success to recreate a new database with the Name AutoCorrect check boxes turned off, or close all RecordSets and databases.

    Best regards.

    Said


  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    My application consists of a back-end database which contains tables, forms, queries, and reports
    back ends should only contain tables, front ends contain forms, queries reports. Your setup does not sound like the normal way to do things and might be the reason for the problem. Suggest provide more information on why you have this setup. Also clarify where your backend and frontend files are located and whether or not the app is (or can be) multi user.

    The back-end database closes normally, while the front-end restarts itself twice with an unloaded database; once when closing the back-end database and another when closing itself. If closing the back-end database is deleted, the back-end database itself is restarted.
    would need to see the code that does this, plus any code in the back end which is triggered when it is opened or closed (e.g. autoexec or display form)

  3. #3
    Said is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2018
    Location
    Alexandria, Egypt
    Posts
    6
    Hi,

    First point: You are right with regard to normal front and back ends, which I have followed later on when multiple data-entry-points are considered; where the back-end is split into back-end 1 (Access 2007) and back-end 2 (SQL Server 2008). Back-end 1 contains forms, queries, and reports while back-end 2 contains tables. Front-end database (Access 2007) remains the same either ways. It contains independent procedures which process the data in the tables and queries and then output reports. Changes are most frequently in the rules and conditions contained in the front-end.

    Second point:
    In the front-end:

    Public dbSos As Database, dbSosdata As New Access.Application ' dbSos and dbSosdata refer to the same database. 1st is used for record sets manipulation and 2nd for print.

    Public Sub Report_Optimal_Solution()
    dbSos.Close
    With dbSosdata
    .OpenCurrentDatabase "c:\sos\sosdata.accdb"
    .DoCmd.OpenReport "schedule_optimization_report_qry"
    .CloseCurrentDatabase
    End With
    End Sub

    In the back-end:

    When open:

    Private Sub Form_Open(Cancel As Integer)

    Dim ExpDate As Date
    ExpDate = "01/01/9999"
    DoCmd.Maximize
    If Date > ExpDate Then
    DoCmd.Quit
    End If
    End Sub

    When close:

    Private Sub Exit_Click()
    On Error GoTo Err_Exit_Click
    Application.Quit
    Exit_Click:
    Exit Sub
    Err_Exit_Click:
    MsgBox Err.Description
    Resume Exit_Click
    End Sub

    Observation: when the front-end is tried without calling the .dll subroutine and ignoring the above-mentioned 'With dbSosdata ....', the front-end closes normally, while doing one of these two cases results in Access restart. In the second case, if dbSosdata is opened without close, the back-end itself restarts. But if closed, unloaded Access restarts.

    Best regards.

    Said

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    pretty sure this won't work

    If Date > ExpDate Then

    because this

    ExpDate = "01/01/9999"

    will fail - you can't assign a string to a date without using # or a function such as datevalue. So as far as I can see your if statement will always return true, so it always quits

    neither of these

    dbSos
    dbSosdata

    appear to have been populated, perhaps they have in other code, perhaps not, only you know.


    this is opening a report

    DoCmd.OpenReport "schedule_optimization_report_qry"

    this code relates to a form

    Private Sub Form_Open(Cancel As Integer)

    Dim ExpDate As Date
    ExpDate = "01/01/9999"
    DoCmd.Maximize
    If Date > ExpDate Then
    DoCmd.Quit
    End If
    End Sub

    this might be a form or report and presumably relates to a control


    Private Sub Exit_Click()
    On Error GoTo Err_Exit_Click
    Application.Quit
    Exit_Click:
    Exit Sub
    Err_Exit_Click:
    MsgBox Err.Description
    Resume Exit_Click
    End Sub


    So I am unable to determine the flow of the code

    Suggest you put in a few breakpoints and step through the code, checking values as you go

  5. #5
    Said is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2018
    Location
    Alexandria, Egypt
    Posts
    6
    Hi,

    a) 'If Date > ExpDate Then' has been debugged and it works alright.

    b) dbSos is set to open via 'Set dbSos = DBEngine.Workspaces(0).OpenDatabase("c:\sos\sosdat a.accdb") and dbSosdata is set to open via 'dbSosdata.OpenCurrentDatabase "c:\sos\sosdata.accdb" '

    c) Appreciated if you review my Observation mentioned in my previous reply. I think the problem is there, but I don't know why?

    Best regards.

    Said

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    I'm sorry I can't follow your logic either.
    Recently someone wanted code to restart the current application automatically without using a script file.
    When you've worked out what causes yours to do exactly that, could you please post it here for the benefit of others.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Observation: when the front-end is tried without calling the .dll subroutine and ignoring the above-mentioned 'With dbSosdata ....', the front-end closes normally
    I don't see a .dll and I don't see a close relating to the front end outside the with

  8. #8
    Said is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2018
    Location
    Alexandria, Egypt
    Posts
    6
    Hi Ridders52,

    Why and how Access restarts itself is unknown to me and restarting is not desirable. I'm sorry for being unhelpful to you.

    Best regards.

    Said

  9. #9
    Said is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2018
    Location
    Alexandria, Egypt
    Posts
    6
    Hi Ajax,

    A .dll is a very long subroutine which is called by a Call statement in the front-end according to a declaration statement. Which one you want to see; the subroutine, the Call statement, or the declaration statement? Closing the front-end is the same as shown under When closed in my previous reply. Please follow the link:

    https://social.technet.microsoft.com...updeploylegacy

    where a similar case is posted.

    Best regards.

    Said

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    It wasn't me who wanted to know how to trigger a restart and I realise that's the exact opposite of what you want.
    From the link it seems you've already tried copying everything to a fresh database and that didn't work.
    The problem with doing that is that if any of your code or database objects re corrupted, they are copied to the new database.

    Try decompiling as that will remove any corrupted code.
    There is a good explanation at http://www.fmsinc.com/MicrosoftAcces.../Decompile.asp
    Also on that site, see this related article http://fmsinc.com/MicrosoftAccess/Er...Convention.asp
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    Said is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2018
    Location
    Alexandria, Egypt
    Posts
    6
    Hi Ridders52 and Ajax,


    Thank you for help. There are two reasons why Access restart itself. One reason is the .dll subroutine called by the front-end, which is now being solved by fixing an
    error within the subroutine. The second is that in the front-end I'm using two database names for the back-end; dbSos and dbSosdata. The first is used for record sets
    manipulation and processing while the second for printing the results. Before beginning the processing I opened dbSos via
    'Set dbSos = DBEngine.Workspaces(0).OpenDatabase("c:\sos\sosdat a.accdb"). After finishing the processing I close dbSos and open dbSosdata to open a report in the
    back-end, as givin by the declaration and the statements shown below:


    Public dbSos As Database, dbSosdata As New Access.Application
    Public Sub Report_Optimal_Solution()
    dbSos.Close
    With dbSosdata
    .OpenCurrentDatabase "c:\sos\sosdata.accdb"
    .DoCmd.OpenReport "schedule_optimization_report_qry"
    .CloseCurrentDatabase
    End With
    End Sub


    It is observed that if the 'With dbSosdata' statements above are ignored, Access does not restart. Also, if the 'DoCmd.OpenReport' in the With is ignored, Access
    restarts itself with an unloaded database. And, if the 'CloseCurrentDatabase' in the with is ignored, Access restarts itself with a loaded database. The decompiling
    does not solve the second reason for Access restart. I think the problem is in giving two names for the same back-end the way described above. I don't know why?


    Best regards.


    Said


    Best regards.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-20-2014, 07:51 AM
  2. Replies: 37
    Last Post: 01-29-2013, 10:50 AM
  3. Report Restarts Itself And Never Completes
    By VariableZ in forum Reports
    Replies: 10
    Last Post: 03-01-2012, 10:47 PM
  4. Unable to close Excel from Access 2007
    By Phred in forum Programming
    Replies: 4
    Last Post: 01-14-2012, 01:58 PM
  5. Disable App Close button in 2007
    By ajetrumpet in forum Programming
    Replies: 3
    Last Post: 09-05-2010, 11:32 PM

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