Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-access > #10994
| 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-12 18:47 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <mqft7v$e23$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> <mqa5v4$13t$1@dont-email.me> <mqfg2n$r8q$1@dont-email.me> |
Hi Ron, Am 12.08.2015 um 15:02 schrieb Ron Paii: > 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. > > Any operation involving Null results in Null. > ? Null > 0 > outputs > Null > That's it and the if command will interpret it as FALSE. > The following code > > Public Sub TestNull() > > If Null = True Then > Debug.Print "Null = True" > Else > Debug.Print "Null = False" > End If > > If Null = False Then > Debug.Print "Null = False" > Else > Debug.Print "Null = True" > End If > > End Sub > > TestNull > Outputs > Null = False > Null = True > > I wish VBA would instead raise an error. It would be easer to catch > logic errors involving Null. > Maybe. I prefer extra handling of the special case that something evaluates to null and not to mention the tristate checkboxes! > ' PS The following changes should make the code more stable > > Private Sub CompanyFind_AfterUpdate() > on error goto errCompanyFind_AfterUpdate > Dim rs As Object > If nz(Me.CompanyFind.Column(3),0) > 0 Then > Set rs = Me.Recordset.Clone > if rs.recordcount > 0 then ' I like to be paranoid when working on > recordsets > > ' Str() indicates [ID] is text, so I added quotes to the search. > ' Str() will output a leading space if number is positive. > ' Str() will raise an error if you pass it a string that is > not a number. > > rs.FindFirst "[ID] =' " & Str(Nz(Me![CompanyFind].Column(3), > 0)) & "'" > If Not rs.Nomatch Then > Me.Bookmark = rs.Bookmark > Else: > MyCompanySearch > endif > else > MyCompanySearch > End If > > doneCompanyFind_AfterUpdate: > on error resume next > set rs = nothing ' Never hurts to cleanup after yourself > exit sub > > errCompanyFind_AfterUpdate: > debug.print err.description > resume doneCompanyFind_AfterUpdate > End Sub I agree with you, an explicit error handling is recommended. Ulrich
Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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