Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #10981

Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working")

From Ulrich Möller <knobbi38@arcor.de>
Newsgroups comp.databases.ms-access
Subject Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working")
Date 2015-08-10 14:39 +0200
Organization A noiseless patient Spider
Message-ID <mqa5v4$13t$1@dont-email.me> (permalink)
References <f5d96247-5024-4736-a974-b399d67f3583@googlegroups.com> <mqa2um$map$1@dont-email.me> <mqa4al$r3k$1@dont-email.me>

Show all headers | View raw


Am 10.08.2015 um 14:11 schrieb Ron Paii:
>
>
> "Ulrich Möller" <knobbi38@arcor.de> wrote in message 
> news:mqa2um$map$1@dont-email.me...
>> Am 09.08.2015 um 08:04 schrieb magmike:
>>> I know this might sound strange, but when I first open my database 
>>> (ProspecForm opens), if I choose to use the CompanyFind 
>>> dropdown/combo box on the form to to choose the record ProspectForm 
>>> will populate with, it causes "Microsoft Access has stopped 
>>> working". However, if I first cycle through a record or two using 
>>> the navigation buttons, and then use the CompanyFind dropdown/combo 
>>> box, it is fine the rest of the time the database is open.
>>>
>>> Here is the offending code:
>>>
>>> Private Sub CompanyFind_AfterUpdate()
>>>      Dim rs As Object
>>> If Me.CompanyFind.Column(3) > 0 Then
>>>      Set rs = Me.Recordset.Clone
>>>      rs.FindFirst "[ID] = " & Str(Nz(Me![CompanyFind].Column(3), 0))
>>>      If Not rs.EOF Then Me.Bookmark = rs.Bookmark
>>>      Else:
>>>      MyCompanySearch
>>> End If
>>> End Sub
>>>
>>>
>>>
>>> Any ideas?
>>>
>>> Thanks in advance for your help,
>>> magmike
>> Maybe you have some timing issues. The records in the combobox will 
>> be loaded asynchronously to the rest of the form. I don't know how 
>> many records will be loaded into your combo so it might took a little 
>> while.
>>
>> Try to force loading the recordset from the combo in the CompanyFind 
>> enter_event with:
>> lngReccordCounts = CompanyFind.ListCount
>>
>> and second, a modification of the original code to a more common usage:
>>
>> Private Sub CompanyFind_AfterUpdate()
>>   Dim rs As DAO.Recordset
>>   If nz(Me.CompanyFind.Column(3),0) > 0 Then
>>     Set rs = Me.Recordset.Clone
>>     rs.FindFirst "[ID] = " & Cstr(Nz(Me![CompanyFind].Column(3), "0"))
>>     if rs.NoMatch Then
>>       MyComanySearch
>>     else
>>       Me.Bookmark = rs.Bookmark
>>     End If
>>   end if
>>   set rs = Nothing
>> End Sub
>>
>> At first you should try it without the code in the enter event and if 
>> it doesn't work for you, add the given code for the enter event and 
>> try it again.
>>
>> Ulrich
>>
>
> Ulrich fix, if itworks "If nz(Me.CompanyFind.Column(3),0) > 0 Then", 
> indicates that the control is null which makes the "If" statement 
> without "NZ" invalid. VBA will ignore the statement and continue to 
> the next line. 
No, without the nz(..) the comparison will be see if NULL > 0 then ...  
which will always evaluate to FALSE and don't throw any error, because 
it is a valid statement! It is only for better reading and a cleaner 
style, how you want.
> The error will occur on the Recordset.Clone or the rs.FindFirst. You 
> should be using "On Error" code in you functions to catch these 
> errors. Question, does the Access crash happen when running under full 
> Access or only on Runtime? Without error checking, full Access should 
> halt with an un-handled exception error, Runtime fill crash.
The real think is the invalid if then else statement where magmike try 
to assign the bookmark, but this may although only a formatting issue in 
my newsreader. Anyway, the code should be rewritten in a more convenient 
style.

Ulrich

Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") magmike <magmike7@yahoo.com> - 2015-08-08 23:04 -0700
  Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") Ulrich Möller <knobbi38@arcor.de> - 2015-08-10 13:48 +0200
    Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") "Ron Paii" <None@none.com> - 2015-08-10 07:11 -0500
      Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") Ulrich Möller <knobbi38@arcor.de> - 2015-08-10 14:39 +0200
        Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") "Ron Paii" <None@none.com> - 2015-08-12 08:02 -0500
          Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") Ulrich Möller <knobbi38@arcor.de> - 2015-08-12 18:47 +0200
  Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") magmike <magmike7@yahoo.com> - 2015-08-11 07:54 -0700
  Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") magmike <magmike7@yahoo.com> - 2015-08-11 09:32 -0700
    Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") Ulrich Möller <knobbi38@arcor.de> - 2015-08-12 01:54 +0200
  Re: AfterUpdate Code causes Access failure ("Microsoft Access has stopped working") Patrick Finucane <patrickfinucanetx@gmail.com> - 2015-08-11 12:30 -0700

csiph-web