Unexplained Exit of Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #16
    As an addendum to that, and only for anyone interested in such things, I actually find that I use the Replace() technique so much that I even wrote a function to handle multiple pairs of parameters for replacing.

    I have to replace any posted code with multiple calls to Replace() so that it makes sense generally in the forums.
    Code:
    'MultiReplace replaces all occurrences of varParam in strMain with varReplace.
    'Using VbBinaryCompare means that case is not ignored.
    Public Function MultiReplace(ByRef strMain As String, _
                                 ByVal varParam As Variant, _
                                 ByVal varReplace As Variant, _
                                 ParamArray avarArgs())
        Dim intIdx As Integer
    
        If (UBound(avarArgs) - LBound(avarArgs)) Mod 2 = 0 Then Stop
        MultiReplace = Replace(Expression:=strMain, _
                               Find:=Nz(varParam, ""), _
                               Replace:=Nz(varReplace, ""), _
                               Compare:=vbBinaryCompare)
        For intIdx = LBound(avarArgs) To UBound(avarArgs) Step 2
            MultiReplace = Replace(Expression:=MultiReplace, _
                                   Find:=Nz(avarArgs(intIdx), ""), _
                                   Replace:=Nz(avarArgs(intIdx + 1), ""), _
                                   Compare:=vbBinaryCompare)
        Next intIdx
    End Function

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #17
      Originally posted by NeoPa
      Anytime ADezii.

      Did you find the reasoning made sense to you?
      Do they sound like techniques you may want to take up?
      Did you find the reasoning made sense to you?
      The reasoning made perfect sense to me, NeoPa
      Do they sound like techniques you may want to take up?
      I already made the change to single line Declarations, and eliminated all multi-line Statements, I guess anything is possible. (LOL).

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #18
        LOL - I like it ADezii :)

        But I just remembered I haven't even done Fish the courtesy of replying properly to his post :(

        I will get to it immediately.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #19
          Originally posted by FishVal
          Hi, Adrian.

          It is really weird. I have only a couple of guesses.
          • did you try to explicitely pass form name as argument to DoCmd.Close method?
          • is there any code in OnClose event handler?
          • in step mode, does Access crash immediately after executing DoCmd.Close?
          • what will happen if you disable error trapping?


          Regards,
          Fish
          1. I did try that - it behaved in exactly the same way.
          2. Good question - I do have a class that encapsulates forms and handles un-hiding the calling form when the called one is closed. In that sense code IS run on closure of the form.
          3. Although I'm unable to test this now, I do know from running this after changes have been made to the design of the form, that the .Close method is in progress already (or even completed) as the Save Changes prompt comes up before the application disappears.
          4. Error trapping has now been disabled and the problem still exists.

          Comment

          Working...