Page 4 of 6 FirstFirst 123456 LastLast
Results 46 to 60 of 82
  1. #46
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    More stuff on the screwed-up Load event:



    https://www.access-programmers.co.uk...firing.250511/

    Haven't tried everything recommended there yet - it's late here. But I do have such stuff in the subforms of the misbehaving form - references to the Parent form. I wonder, despite my code not running when the unwanted quitting occurs, if a similar situation is not causing my underlying problem. Obviously, the coding constructs described in that thread cause some hare-brained activity inside the Access app. That could easily be the kind of thing that only bombs sometimes, since it is already wandering into uncharted territory that is causing some seriously screwed-up behavior, and could crap out on its own, when my code is not running - like a time bomb, the mess sets up some conditions that Access randomly sometimes trips over later, while contemplating its own navel, rather than when specifically running VBA code.

    Getting rid of the start-up form has helped, but not completely eliminated the problem. I will try to completely get rid of the Load events, and use only Open. A while back, I read somewhere that Open should only be used for testing things that may cause you to want to cancel the form opening, since only it has the Cancel parameter, and everything else should go into the Load event. It sounded reasonable, so I tried it and suffered no ill effects, until this started happening. May be another case of free advice ultimately being really expensive.

  2. #47
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    Okay, that wasn't it. Just transferred everything from Load into Open, decompiled, C & R, compiled, C& R again, and closed it. Tried starting it up, and it quit immediately after opening three times in a row, fourth attempt stayed open and is running perfectly. Another dead-end idea.

    It did fix the dialog form that was running the Load event on form close. I didn't investigate in detail, but I do have the sort of setup described in the link above, where the subform refers to the parent and causes the parent's Current event to fire. Removing the Load event code entirely and doing everything in the Open event has that form behaving correctly now. But doing the same for the main form/subform did not fix the problem that is the root of this thread - the entire Access app suddenly quitting for no reason shortly after starting.

  3. #48
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,930
    One thing to try if you have subforms possibly causing an issue, is to "force" the load order.
    e.g. set the sub form container controls source object to nothing. Then in the parent form load event, set the object when you want it, not when access decides to load it.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #49
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    Quote Originally Posted by Minty View Post
    One thing to try if you have subforms possibly causing an issue, is to "force" the load order.
    e.g. set the sub form container controls source object to nothing. Then in the parent form load event, set the object when you want it, not when access decides to load it.
    Interesting idea - thank you. I have a few cases where I have the record source blank, but that is to speed up loading of forms that would otherwise take a long time, for something that use may not even need to do. Some forms are capable of certain tasks without having any records loaded, and the user may want to just do those. They load records only when needed.

    I'll keep this in mind in case I run into such problems again. Appreciate the tip.

  5. #50
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    So I now have the main form opening directly, and all start-up code solely in the main form's Open event, or routines called from the Open event. Still crashes randomly, at three different places. One is immediately into the Open event routine, one is several steps in, in a subroutine named Detour, called from the Open event, and one is again after everything has settled and all my code has stopped executing.

    I have the code opening the VBA editor, so that I can see output of the Debug.Print statements. It makes a difference whether I have Access already open, and start the app from there, or have Access closed, and start everything with a double-click from File Explorer. Both crash, but the former crashes less often. Trying to hit Alt-F11 quickly enough after starting from nothing was tricky, so I added this line of code to open the VBE window immediately. This is the main form, with NO other code executing first.

    Here is the Open event code:
    Code:
    Private Sub Form_Open(Cancel As Integer)
    Dim i&, j&, k&, ctl As Control, rst As DAO.Recordset, x$, y$
    Application.VBE.MainWindow.Visible = True
    DoEvents
    Debug.Print "O1"
    DoEvents ' First crash point is here - debug window prints 01, but not 02. Used to be some code between these two, which I removed, but happened to leave both print statements.
    Debug.Print "O2"
    
    
    ' Nechci aby to lidé spouštěli ze sítě, je to náročný na síťový provoz a dělá místní zápisy, což by kolidovalo pro více uživatelů.
    ' Je to míněné aby si každý stáhl a spustil svou vlastní kopií.
    
    
    If CurrentProject.Name <> "Paleontologie.accdb" Then
        MsgBox "Tato aplikace se musí jmenovat Paleontologie.accdb" & vbCrLf & vbCrLf & "Skutečný název je " & CurrentProject.Name & vbCrLf & vbCrLf & "V tomto stavu nejde spustit.", vbCritical + vbOKOnly, "Špatný název"
        Cancel = True
        Application.Quit
    End If
    Debug.Print "O3"
    
    
    Set FS = CreateObject("Scripting.FileSystemObject")
    If Left$(currentdb.Name, 2) = "\\" Then
        MsgBox "Tento formulář je určený pro použití jako klient, umístený na místním počítači." & vbCr & vbCr & "Zkopírujte si tento soubor do vlastního počítače a spusťte ho tam.", vbOKOnly + vbCritical, "Chybné spuštění."
        Application.Quit
        Exit Sub
    End If
    Debug.Print "O4"
    
    
    If Not IsLocalDrive(Left$(currentdb.Name, 1)) Then
        MsgBox "Tento formulář je určený pro použití jako klient, umístený na místním počítači." & vbCr & vbCr & "Zkopírujte si tento soubor do vlastního počítače a spusťte ho tam.", vbOKOnly + vbCritical, "Chybné spuštění."
        Application.Quit
        Exit Sub
    End If
    Debug.Print "O5"
    
    
    CestaDoServeru_Aplikace = ReadCustomDocumentProperty("CestaDoServeru_Aplikace")
    If Right$(CestaDoServeru_Aplikace, 1) <> "\" Then CestaDoServeru_Aplikace = CestaDoServeru_Aplikace & "\"
    ' Když není mapovaná jednotka, tak nemáme přístup ke správně složce ne serveru, vypadneme.
    If Not NetworkPathExists(CestaDoServeru_Aplikace) Then
        MsgBox "Cesta '" & CestaDoServeru_Aplikace & "' není dostupná, což musí být, aby databáze fungovala." & vbCr & vbCr & "Obraťte se na síťového správce pro oddělení.", vbOKOnly + vbCritical, "Chybné spuštění."
        Application.Quit
        Exit Sub
    End If
    Debug.Print "O6"
    
    
    CestaDoServeru_Prilohy = ReadCustomDocumentProperty("CestaDoServeru_Prilohy")
    If Right$(CestaDoServeru_Prilohy, 1) <> "\" Then CestaDoServeru_Prilohy = CestaDoServeru_Prilohy & "\"
    ' Když není mapovaná jednotka, tak nemáme přístup ke správně složce ne serveru, vypadneme.
    If Not NetworkPathExists(CestaDoServeru_Prilohy) Then
        MsgBox "Cesta '" & CestaDoServeru_Prilohy & "' není dostupná, což musí být, aby databáze fungovala." & vbCr & vbCr & "Obraťte se na síťového správce pro oddělení.", vbOKOnly + vbCritical, "Chybné spuštění."
        Application.Quit
        Exit Sub
    End If
    Debug.Print "O7"
    
    
    Detour
    
    
    Debug.Print "1"
    DoEvents
    Debug.Print CurrentProject.AllForms("KeepAlive").IsLoaded
    DoEvents
    
    
    ' Rozsvítit titul červeně, když používáme pokusná data.
    'If Not CurrentProject.AllForms("Start").IsLoaded Then
    '    MsgBox "Musí se spouštět přes formulář 'Start'", vbCritical, "Nejde spustit samostatně"
    '    Stop
    ''    DoCmd.Close ObjectType:=acForm, ObjectName:=Name
    ''    End
    'End If
    
    
    Debug.Print "1.1"
    
    
    'PauseHeaderYellow True
    
    
    SetTitul
    Debug.Print "1.2"
    gbl_ctlCaption ctl:=lblFiltrTaxLokNmbr, text:=tglFiltrTaxLok.OptionValue
    Debug.Print "1.3"
    gbl_ctlCaption ctl:=lblFiltrKompletNmbr, text:=tglFiltrKomplet.OptionValue
    Debug.Print "1.4"
    gbl_ctlCaption ctl:=lblFiltrInventNmbr, text:=tglFiltrInvent.OptionValue
    Debug.Print "1.5"
    gbl_ctlCaption ctl:=lblFiltrVyberNmbr, text:=tglFiltrVyber.OptionValue
    Debug.Print "1.6"
    gbl_ctlCaption ctl:=lblFiltrRozsahNmbr, text:=tglFiltrRozsah.OptionValue
    Debug.Print "1.7"
    gbl_ctlCaption ctl:=lblFiltrOriginNmbr, text:=tglFiltrOrigin.OptionValue
    Debug.Print "1.8"
    gbl_ctlCaption ctl:=lblFiltrExterniNmbr, text:=tglFiltrExterni.OptionValue
    Debug.Print "1.9"
    
    
    gbl_ctlsClearControlTipText arr:=Array(tglFiltrPolicka, tglFiltrTaxLok, tglFiltrKomplet, tglFiltrInvent, tglFiltrVyber, tglFiltrRozsah, tglFiltrOrigin, tglFiltrExterni)
    FilterOn = False
    DoEvents
    
    
    ' Nastavit 'příští' akcesitní číslo pro letošní rok
    PristiAkcesit
    Debug.Print "2"
    DoEvents
    
    
    ' Tady už máme jméno ze startovacího formuláře. Jméno do škatulky na formuláři, pak podle toho ovládat viditelnosti a přístupy různých prvků. Startovací jméno dále nepotřebujeme.
    With gbl_UzivatelInfo
        gbl_ctlCaption ctl:=lblUzivatel, text:=.LclKrestni & " " & .LclPrijmeni
        gbl_ctlCaption ctl:=lblPovoleni, text:=Switch(.Kurator, "Kurátor", .CES, "CES-Kurátor", .Admin, "Administrátor", .Uzivatel, "Uživatel", .Knihovnik, "Knihovník", .Host, "Host", True, "??????")
        gbl_ctlsVisible arr:=Array(cmdSmazatZ, cmdSmazatZs, cmdPodrobnostiWidth, cmdPodrobnostiWidth), stav:=.Admin
        gbl_ctlAble ctl:=cmdEditTaxonomie, stav:=.AsponKurator
    DoEvents
        gbl_ctlCaption ctl:=cmdDoDo, text:="DoDo"
    DoEvents
        If .LclKrestni = "Host" Then
            gbl_ctlsDisable arr:=Array(cmdRezervCisla, cmdInventVDepozitari, cmdDoDo)
            With cmdNovyAkcesit
                .Enabled = False
                .ControlTipText = ""
            End With
        Else
            cmdNovyAkcesit.ControlTipText = "Nové akcesitní číslo," & vbCrLf & "automaticky dá letos a příští volné číslo."
            If .LclSkupina = "Admin" Or .LclSkupina = "CES" Then cmdNovyAkcesit.ControlTipText = cmdNovyAkcesit.ControlTipText & vbCrLf & "Alt / Klik dovolí přidat Akces záznam s libovolném číslem."
            gbl_ctlEnable ctl:=cmdDoDo
        End If
    End With
    DoEvents
    
    
    txt_hdn_Hranice = ReadCustomDocumentProperty("HranicePoctu")
    Debug.Print "3"
    DoEvents
    
    
    ' Nastavit pucky pro písmenové filtry.
    Set rst = currentdb.OpenRecordset("spEvidenceLettersWithCount", dbOpenSnapshot)
    DoEvents
    
    
    Set gbl_LtrFiltrTgls = New Collection
    For j = 0 To 89
        Set ctl = Controls("tglEL" & Right$(CStr(j + 100), 2))
        If rst.EOF Then
            gbl_ctlVisible ctl:=ctl, stav:=False
        Else
            x = rst.Fields("EvidenceLetter")
            k = rst.Fields("Kolik")
            If x = "1e" Then
                tglELPrvni.ControlTipText = "Celkový počet " & x & " záznamů = " & CStr(k)
                rst.MoveNext
                x = rst.Fields("EvidenceLetter")
                k = rst.Fields("Kolik")
                gbl_LtrFiltrTgls.Add tglELPrvni, tglELPrvni.Name
            End If
            If (Len(x) = 1 And (CLng(Right$(ctl.Name, 2)) Mod 3) > 0) _
            Or (Len(x) = 2 And Right$(x, 1) = "s" And (CLng(Right$(ctl.Name, 2)) Mod 3) <> 1) _
            Or (Len(x) = 2 And Right$(x, 1) <> "s" And (CLng(Right$(ctl.Name, 2)) Mod 3) < 2) Then
                i = i + 1
                gbl_ctlVisible ctl:=ctl, stav:=False
            Else
                ctl.Caption = x
                ctl.Visible = True
                ctl.ControlTipText = "Celkový počet " & x & " záznamů = " & CStr(k) & vbCrLf & "Držením Ctrl se přidá písmeno do zběru." & vbCrLf & "Držením Alt se vypne všechno, kromě drženého."
                gbl_ctlAble ctl:=ctl, stav:=k > 0
                i = i + 1
                rst.MoveNext
                gbl_LtrFiltrTgls.Add ctl, ctl.Name
            End If
        End If
    Next j
    rst.Close
    Set rst = Nothing
    DoEvents
    
    
    rctKatalogFiltry.Height = tglEL00.top - 20 + (283 * ((i + 1) \ 3))
    Debug.Print "4"
    DoEvents
    
    
    gbl_ctlVisible ctl:=lblAkcesitChyba, stav:=False
    LoadSeznamFilters
    DoEvents
    
    
    CurrentUserFilter
    DoEvents
    
    
    With optAkcesFiltry
        .Tag = "FiltrNoRecords"
        For i = 0 To .Controls.Count - 1
            If Left$(.Controls(i).Name, 3) = "tgl" Then
                gbl_ctlVisible ctl:=Controls("lbl" & Mid$(.Controls(i).Name, 4)), stav:=False
                gbl_ctlAble ctl:=.Controls(i), stav:=.Controls(i).Name = "tglFiltrVse"
            End If
        Next i
    End With
    Debug.Print "5"
    DoEvents
    
    
    ' Načíst schované 'pamatovací' pucky posledních šest Akcesitů. Opět se přidaj, jak se budou Akcesity hledat.
    For i = 1 To 6
        y = "cmdPA" & CStr(i)
        x = ReadCustomDocumentProperty(y)
        With Controls(y)
            If x = ";" Then
                .Enabled = False
                .Caption = ""
            Else
                .Enabled = True
                j = InStr(x, ";")
                .Tag = Left$(x, j - 1)
                .Caption = Mid$(x, j + 1)
            End If
        End With
    Next i
    Debug.Print "6"
    DoEvents
    
    
    ' Vyvolat poslední hodnoty
    i = gbl_FilterTextsRozsah.PlusMinus
    If i > 0 Then
        txt_hdn_PlusMinus = CStr(i)
    Else
        txt_hdn_PlusMinus = Null
    End If
    DoEvents
    
    
    gbl_ctlDisable ctl:=cmd_hdn_NajdiDrEvidPlusMinus
    i = gbl_FilterTextsRozsah.PrvniPosledni
    If i > 0 Then
        txt_hdn_PoslednichX = CStr(i)
        gbl_ctlEnable ctl:=cmd_hdn_PoslednichX
    Else
        gbl_ctlDisable ctl:=cmd_hdn_PoslednichX
    End If
    DoEvents
    
    
    sfPodrobnosti.Width = PodrobnostiWide
    Debug.Print "7"
    DoEvents
    
    
    ' Přepnout formulář na Akcesity nebo jenom druhou evidence.
    optAkcesityDruhaEvidence = ReadCustomDocumentProperty("ZobrazeniAkcesityDruhaEvidence")
    DoEvents
    
    
    DoToggle2Evid stav:=optAkcesityDruhaEvidence
    DoEvents
    
    
    FormatlblRS IIf(gbl_UzivatelInfo.Pokusy Or gbl_UzivatelInfo.Admin, "Large", "Small")
    Section(0).Height = 1
    DoEvents
    
    
    gbl_ctlCaptionClear ctl:=lblRS
    ReloadMaxNumbers
    Debug.Print "8"
    DoEvents
    
    
    Set lcl_hldInventDataDepozitar_Akc = New clsDepozitar
    Set gbl_PodrobDataDepozitar = New clsDepozitar
    DoEvents
    
    
    With DoCmd
        .Maximize
        .Close acForm, gbl_UzivatelInfo.SplashForm
    End With
    'PauseHeaderYellow False
    Debug.Print "9"
    DoEvents
    
    
    'Set rs = CurrentDb.OpenRecordset("SELECT top 1 1 from AO_vwStratigrafieLito", dbOpenDynaset, dbSeeChanges)
    'rs.MoveLast
    'MsgBox rs.RecordCount & " Record queried"
    txtSrchAkcesitCely.SetFocus
    DoEvents
    
    
    End Sub
    Detour routine, with second crash point:

    Code:
    Private Sub Detour()
    Dim rst As DAO.Recordset, oSysInfo As ActiveDs.WinNTSystemInfo, MachineName$, doc As Object, db As DAO.Database, cnt As DAO.Container, props(), i&, yp$, x$
    Debug.Print "Starting detour"
    DoCmd.OpenForm "KeepAlive", acNormal, , , , acHidden
    Debug.Print "Skipping KeepAlive"
    
    
    With currentdb
        Set qdf_GPsp = .QueryDefs(GPStoredProc)
        Set qdf_GPcmd = .QueryDefs(GPStoredCmd)
    End With
    DoEvents
    Debug.Print "GP queries"
    
    
    ' Podíváme se, jestli je novější verze ke stažení. Když je, uživatel by ji měl stáhnout a tedy odsud se už nevrátíme.
    TestVersion
    DoEvents
    Debug.Print "Test version"
    
    
    ' Spojka do databázového motoru.
    ' Uživatelské jméno. Když běži u mne, zeptá se, jaké jméno má použivat, jinak rovnou vezmě jméno z počítače. Mne také varuje, že se hrabu v živích datech - pro ostatní je takové varování zbytečné.
    Set oSysInfo = New ActiveDs.WinNTSystemInfo
    gbl_UzivatelInfo.LclUcet = oSysInfo.UserName
    Set oSysInfo = Nothing
    DoEvents
    
    
    If gbl_UzivatelInfo.LclUcet = "DanesPe" Then
        gbl_UzivatelInfo.StartUzivatelJeDanes = True
        gbl_UzivatelInfo.UzivatelJeDanes = True
    End If
    DoEvents
    Debug.Print "SysInfo"
    
    
    CheckKteraDatabaze
    DoEvents
    Debug.Print "KteraDB"
    
    
    ' Prints the above, then quits
    
    
    If gbl_UzivatelInfo.StartUzivatelJeDanes = True Then
        DoCmd.OpenForm "StartSelectUzivatel", acNormal, , , , acDialog, "Daneš, Petr"
        If Len(gbl_UzivatelInfo.LclUcet) = 0 Then End
    End If
    DoEvents
    Debug.Print "StartSelectUzivatel"
    
    
    GetDomainUserInfo gbl_UzivatelInfo, gbl_UzivatelInfo.LclUcet
    DoEvents
    Debug.Print "GetDomainUserInfo"
    
    
    Set gbl_LtrFltr = New cls_singl_Katalogs
    Set gbl_FilterTextsObsah = New cls_singl_FiltrObsah
    Set gbl_FilterTextsTaxLok = New cls_singl_FiltrTaxLok
    Set gbl_FilterTextsKomplet = New cls_singl_FiltrKomplet
    Set gbl_FilterTextsInvent = New cls_singl_FiltrInvent
    Set gbl_FilterTextsVyber = New cls_singl_FiltrVyber
    Set gbl_FilterTextsRozsah = New cls_singl_FiltrRozsah
    Set gbl_FilterTextsOrigin = New cls_singl_FiltrOrigin
    Set gbl_FilterTextsExtrn = New cls_singl_FiltrExtrn
    DoEvents
    Debug.Print "Filter objects"
    
    
    Set rre = New RegExp
    Set gbl_rre_patterns = New cls_singl_DrEvidRegExpPatterns
    DoEvents
    
    
    With currentdb
        Set qdf_spAkcesitProCustomFind = .QueryDefs("spAkcesitProCustomFind")
        Set qdf_XForm = .QueryDefs("CrosstabOfTables")
        Set qdf_PrilohaAkcesitKniha = .QueryDefs("spPrilohaAkcesitKniha")
        Set qdf_srchAkc_spAkcesIDSrch = .QueryDefs("srchAkc_spAkcesIDSrch")
        Set qdf_srchAkc_AkcesYears = .QueryDefs("srchAkc_spAkcesYears")
        Set qdf_spMaxCisla = .QueryDefs("spMaxCisla")
        Set qdf_spMaxAkcesitLetos = .QueryDefs("spMaxAkcesitLetos")
        Set qdf_vwPrvniAkcesit = .TableDefs("RO_vwPrvniAkcesit")
        Set qdf_FiltrVyber = .QueryDefs("spFiltrVyber")
        Set qdf_lcl_FiltrVyberClear = .QueryDefs("lcl_FiltrVyberClear")
        Set qdf_lcl_SeznamZaznamuPocet = .QueryDefs("lcl_SeznamZaznamu_Pocet")
        Set qdf_lcl_SeznamZaznamuClear = .QueryDefs("lcl_SeznamZaznamuClear")
    
    
        Set qdf_PodrobnostiNaHlavnimPocetAkcesitu = .QueryDefs("Alles_spPodrobnostiNaHlavnimPocetAkcesitu")
        Set qdf_PodrobnostiNaHlavnimPrvniAkcesit = .QueryDefs("Alles_spPodrobnostiNaHlavnimPrvniAkcesit")
        Set qdf_PodrobnostiNaHlavnimStandard = .QueryDefs("Alles_spPodrobnostiNaHlavnim")
        Set qdf_PodrobnostiNaHlavnimVsePolicka = .QueryDefs("Alles_spPodrobnostiNaHlavnimVse")
        Set qdf_PodrobnostiJenAutoID = .QueryDefs("Alles_spPodrobnostiJenAutoID")
        Set qdf_PodrobnostiCelyID = .QueryDefs("Alles_spPodrobnostiCelyID")
        Set qdf_PodrobnostiNaHlavnimMaZaznamVAkcesitu = .QueryDefs("Alles_spPodrobnostiNaHlavnimMaZaznamVAkcesitu")
        Set qdf_PodrobnostiNaHlavnimMaZaznamKdekoli = .QueryDefs("Alles_spPodrobnostiNaHlavnimMaZaznamKdekoli")
        Set qdf_PodrobnostiNaHlavnimPocetPodrobnosti = .QueryDefs("Alles_spPodrobnostiNaHlavnimPocet")
        Set qdf_SousediciAkcesity = .QueryDefs("Alles_spSousediciAkcesity")
        Set qdf_SousediciAkcesityPodleVyberu = .QueryDefs("Alles_spSousediciAkcesityPodleVyberu")
        
        gbl_LtrFltr.LoadAll "1e," & .OpenRecordset("RO_vwEvidenceLettersString").Fields("Letters")
    End With
    DoEvents
    Debug.Print "Record source queries"
    
    
    LoadAkcesitDotazy
    LoadPodrobnostiNaHlavnimDotazy
    DoEvents
    
    
    ' Ukážeme startovací formulář, podle jména uživatele.
    With gbl_UzivatelInfo
        .SplashForm = SetSplashForm
        DoCmd.OpenForm .SplashForm
        DoEvents
    
    
    ' Připravíme formulář k použití, částenčně podle současného uživatele.
        gbl_ctlVisible ctl:=Forms(.SplashForm).lblStartuje, stav:=True
        DoEvents
        FadeBack Forms(.SplashForm).lblStartuje, 0
    End With
    DoEvents
    Debug.Print "Splash form"
    
    
    ' První spuštění?
    ' Smazat staré výbery. Když databáze naposledy běžela na jiném compu, nejspíš u mně, a tedy moje výběry by se měli smazat, a načíst staré, uložené místním uživatelem.
    ' Ale taky tady nemusí být stará kopie, když je to první spuštění v novém účtu nebo novém compu.
    currentdb.Execute "DELETE * FROM lcl_FiltrVyber"
    MachineName = fOSMachineName
    DoEvents
    Debug.Print "Clear lcl_FiltrVyber"
    
    
    If MachineName <> ReadCustomDocumentProperty("CompKdeNaposledyBezel") Then
        yp = Left$(currentdb.Name, InStrRev(currentdb.Name, ".")) & "hld"
        WriteCustomDocumentProperty "CompKdeNaposledyBezel", MachineName
    ' Je v této mašině stará kopie? Jenom když ano můžeme načíst z ní staré hodnoty.
        If FS.FileExists(yp) Then
            Set db = CreateObject("DAO.DBEngine.36").OpenDatabase(yp, False, True)
            Set cnt = db.Containers(1)
            Set doc = cnt.Documents("UserDefined")
            props = Array("FiltrovaciPismena", "JazykTextu", "Zobrazeni2Evidence", "cmdPA1", "cmdPA2", "cmdPA3", "cmdPA4", "cmdPA5", "cmdPA6", "ZobrazeniAkcesityDruhaEvidence", "GPSFormat", "Aret2EvidEvidoval", "Aret2EvidPrepsal", "HranicePoctu", "PlusMinusPodrobnosti", "FiltrRozsah")
            With doc
                On Error Resume Next
                For i = LBound(props) To UBound(props)
                    WriteCustomDocumentProperty props(i), .Properties(props(i))
                Next i
                On Error GoTo 0
            End With
            Set doc = Nothing
            Set cnt = Nothing
            Set db = Nothing
            On Error Resume Next
            Kill yp
            On Error GoTo 0
        End If
    End If
    DoEvents
    Debug.Print "Check for old copy"
    
    
    ' Načist speciální čísla, abychom je nemuseli pak hledat a spojovat
    Set rst = currentdb.OpenRecordset("RO_vwAkcesRubbishHeap", dbReadOnly)
    With rst
        Do Until .EOF
            AkcesAutoIDRubbishList = AkcesAutoIDRubbishList & CStr(.Fields(0)) & ","
            .MoveNext
        Loop
        .Close
        AkcesAutoIDRubbishList = Left$(AkcesAutoIDRubbishList, Len(AkcesAutoIDRubbishList) - 1)
    End With
    Set rst = Nothing
    DoEvents
    Debug.Print "Rubbish list"
    
    
    Set AkcesRecord22011 = New clsAkcesRecordData
    AkcesitNajdi paramAkcesStatus:=AkcesStatus, SrchAkc:="22011", UkazatForm:=False
    If AkcesStatus.CoSeStalo <> AkcStatus.NaselOK Then Stop
    AkcesRecord22011.NalozitAkcesZaznam AkcesAutoID:=AkcesStatus.GoToAkcesAutoID
    
    
    Set AkcesRecord35050 = New clsAkcesRecordData
    AkcesitNajdi paramAkcesStatus:=AkcesStatus, SrchAkc:="35050", UkazatForm:=False
    If AkcesStatus.CoSeStalo <> AkcStatus.NaselOK Then Stop
    AkcesRecord35050.NalozitAkcesZaznam AkcesAutoID:=AkcesStatus.GoToAkcesAutoID
    
    
    Set AkcesRecord36675 = New clsAkcesRecordData
    AkcesitNajdi paramAkcesStatus:=AkcesStatus, SrchAkc:="36675", UkazatForm:=False
    If AkcesStatus.CoSeStalo <> AkcStatus.NaselOK Then Stop
    AkcesRecord36675.NalozitAkcesZaznam AkcesAutoID:=AkcesStatus.GoToAkcesAutoID
    
    
    Set AkcesRecordRezervovana = New clsAkcesRecordData
    AkcesitNajdi paramAkcesStatus:=AkcesStatus, SrchAkc:="999999999/9999", UkazatForm:=False
    If AkcesStatus.CoSeStalo <> AkcStatus.NaselOK Then Stop
    AkcesRecordRezervovana.NalozitAkcesZaznam AkcesAutoID:=AkcesStatus.GoToAkcesAutoID
    
    
    Set AkcesRecordInventarizovana = New clsAkcesRecordData
    AkcesitNajdi paramAkcesStatus:=AkcesStatus, SrchAkc:="888888888/9999", UkazatForm:=False
    If AkcesStatus.CoSeStalo <> AkcStatus.NaselOK Then Stop
    AkcesRecordInventarizovana.NalozitAkcesZaznam AkcesAutoID:=AkcesStatus.GoToAkcesAutoID
    
    
    Set AkcesRecordImportovany = New clsAkcesRecordData
    AkcesitNajdi paramAkcesStatus:=AkcesStatus, SrchAkc:="777777777/9999", UkazatForm:=False
    If AkcesStatus.CoSeStalo <> AkcStatus.NaselOK Then Stop
    AkcesRecordImportovany.NalozitAkcesZaznam AkcesAutoID:=AkcesStatus.GoToAkcesAutoID
    DoEvents
    Debug.Print "Special Akcesits"
    
    
    gbl_ImportPath = PaleoAppPath
    With DoCmd
    '    .OpenForm "Akces", acNormal, , , , acWindowNormal
        DoEvents
        Form_Akces.SetFocus
        DoEvents
        Form_Akces.txtSrchAkcesitCely.SetFocus
        DoEvents
    '    .Close acForm, Name
    End With
    Debug.Print "Set focus"
    
    
    End Sub
    Since it sometimes quits before anything at all has happened, besides opening the VBE window, it looks as if something in the structure is corrupt. I guess I'll try importing everything into a new database again, and if the issue persists, try cutting out pieces to see if I can make it stop - simply removing forms and reports. This will obviously make it crash if I wander into code that tries to refer to such objects, but at least the start-up should work. If something I remove suddenly makes it stop crashing, I will have something further to investigate

  6. #51
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,930
    My one observation is the large number of DoEvents that are present.
    Are these from your attempts to stop it crashing?

    Personally, I would get rid of all of them unless they are required for a specific function to work correctly.
    Generally it allows processing of other events in the background, and I'm unsure what benefits it is giving you here, and conversely may be causing more problems?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #52
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    Quote Originally Posted by Minty View Post
    My one observation is the large number of DoEvents that are present.
    Are these from your attempts to stop it crashing?

    Personally, I would get rid of all of them unless they are required for a specific function to work correctly.
    Generally it allows processing of other events in the background, and I'm unsure what benefits it is giving you here, and conversely may be causing more problems?
    Mostly they were to allow the Debug.Print statements to complete, so I could see how far code gets before bombing. Also, some of them were from attempts to track down various actions. I suspected that there might be conflicts in two long-running actions spawned right after each other. I have run into situations where that was a problem, and putting in a DoEvents to let the machine 'catch its breath' alleviated the problem.

    I can try removing them again - at this point, almost anything is worth a try.

  8. #53
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    Just commented out all the DoEvents in these two routines. Bombed on first attempt to open.

  9. #54
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    3 opens failed, 1 succes, 1 fail, 1 success, 1 fail, 5 success, 1 fail, etc.

  10. #55
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,930
    That helped a lot then It's a very frustrating problem.
    Do you have any properties that might be trying to self reference other properties etc?

    I have recently tripped myself up where a property if not set, was updating a local options table to ensure it was accurate, and wiping out data on a combobox on a form that referenced the same property.
    (Don't ask...)
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #56
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    Quote Originally Posted by Minty View Post
    That helped a lot then It's a very frustrating problem.
    Do you have any properties that might be trying to self reference other properties etc?

    I have recently tripped myself up where a property if not set, was updating a local options table to ensure it was accurate, and wiping out data on a combobox on a form that referenced the same property.
    (Don't ask...)
    No kidding - it's been a long time since I've run into something where I have absolutely no clue about what is happening. I've started chopping out things, trying to isolate something, anything, that might be causing problems. Nothing so far - random alternating of running and quitting.

  12. #57
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    I'm not sure exactly what you mean by properties self-referencing other properties. I don't think I have anything unusual or cyclical in the system, especially since it quits at random points, both in code and when no code is running. Continuing to remove stuff.

  13. #58
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    New version, starting with a clean new database and importing everything. Cut out bunches of stuff - all sorts of external library references, numerous forms, all the code out of a great number of routines, leaving just the stubs. Same results: on random occasions, it starts up and just quits.

  14. #59
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    163
    I picked through the app and found several references to linked tables that no longer existed on the server, and some similar ballast. Cut all that out, high hopes that such a house-cleaning might have helped - nothing. Still bombs.

    But it's now doing it in running code. No errors, and still not in any predictable manner, but at least I have something to try tracking. I am slowly removing places that it goes when it quits. So far, it simply quits someplace else, but I am in a slightly better situation, in that things I am doing are having an effect on the problem.

    I am gradually removing or replacing with stubs everything that it wanders into when quitting, so maybe I will eventually remove or disable something that will make it stop the random quitting.

    I also tried a few other Access databases that I have in the machine, just to see what I can see. Not a peep - every other one runs perfectly.

  15. #60
    isladogs's Avatar
    isladogs is offline Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    4,928
    I do hope you are keeping a record of all these changes!
    At some point, perhaps you will upload something using an Access BE instead of SQL so that members have a chance to assist by looking at the file.
    As it is, all anyone can do is keep making informed guesses...but by now, I think we're all out of ideas without anything to refer to

    Otherwise, good luck. Hopefully you'll get there in the end by yourself.
    Colin (Mendip Data Systems): Website, email
    Try again. Fail again. Fail better.
    A
    sking for help isn't giving up. Its refusing to give up.

Page 4 of 6 FirstFirst 123456 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access Runtime Crash
    By martinmcnally in forum Access
    Replies: 5
    Last Post: 08-16-2018, 06:10 PM
  2. Access crash
    By JennyL in forum Access
    Replies: 6
    Last Post: 01-19-2017, 03:42 AM
  3. debugging access 2013 crash
    By DKP in forum Programming
    Replies: 6
    Last Post: 10-06-2014, 10:23 AM
  4. Access crash
    By Tjaaaa in forum Access
    Replies: 10
    Last Post: 03-07-2014, 05:41 PM
  5. Diagnose Access Crash
    By Gray in forum Forms
    Replies: 0
    Last Post: 05-28-2011, 01:50 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 - Senior Forums