Group:  Microsoft Access » microsoft.public.access.formscoding
Thread: How is 869343 less than 869330?????

Geek News

How is 869343 less than 869330?????
Walter 12/22/2008 9:52:02 PM
This is the code that for some reason isn't following standard mathematical
logic. In my current record, Me.Odometer = 869343. The last Odometer
entered was 869330. My Invalid Odometer message pops up. I put a code break
to see what's happening. varPrevOdometer is showing 869330 and Me.Odometer
is showing 869343. However, it's still going thru the steps as if 869343 is
less than 869330. The values in the "if is less than" step are correct. Can
you please explain to me when the greater than, less than rules changed??
Why is it cancelling and calling the error message?

Private Sub Odometer_BeforeUpdate(Cancel As Integer)

Dim varPrevOdometer As Variant

varPrevOdometer = Me.Parent!PrevOdometer

If Me.Odometer < varPrevOdometer Then
Cancel = True
Me.Odometer.SelStart = 0
Me.Odometer.SelLength = Len(Me.Odometer.Value)
MsgBox _
"The last odometer entered for this truck was " & _
varPrevOdometer & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"

Else
Cancel = False
End If

End Sub
--
Thanks for your help!
Walter
RE: How is 869343 less than 869330?????
Tony 12/22/2008 10:04:01 PM
try this:

Dim varPrevOdometer As Integer

"Walter" wrote:

[Quoted Text]
> This is the code that for some reason isn't following standard mathematical
> logic. In my current record, Me.Odometer = 869343. The last Odometer
> entered was 869330. My Invalid Odometer message pops up. I put a code break
> to see what's happening. varPrevOdometer is showing 869330 and Me.Odometer
> is showing 869343. However, it's still going thru the steps as if 869343 is
> less than 869330. The values in the "if is less than" step are correct. Can
> you please explain to me when the greater than, less than rules changed??
> Why is it cancelling and calling the error message?
>
> Private Sub Odometer_BeforeUpdate(Cancel As Integer)
>
> Dim varPrevOdometer As Variant
>
> varPrevOdometer = Me.Parent!PrevOdometer
>
> If Me.Odometer < varPrevOdometer Then
> Cancel = True
> Me.Odometer.SelStart = 0
> Me.Odometer.SelLength = Len(Me.Odometer.Value)
> MsgBox _
> "The last odometer entered for this truck was " & _
> varPrevOdometer & vbCrLf & _
> "Please enter an odometer greater than or equal " & _
> "to this.", , _
> "Invalid Odometer Entry"
>
> Else
> Cancel = False
> End If
>
> End Sub
> --
> Thanks for your help!
> Walter
RE: How is 869343 less than 869330?????
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 12/22/2008 10:37:25 PM
Agreed. Except I'd use:

Dim varPrevOdometer As Long

In over ten years, I've seen very few actual reasons to use a variant.


Tony wrote:
[Quoted Text]
>try this:
>
>Dim varPrevOdometer As Integer
>
>> This is the code that for some reason isn't following standard mathematical
>> logic. In my current record, Me.Odometer = 869343. The last Odometer
>[quoted text clipped - 27 lines]
>>
>> End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

RE: How is 869343 less than 869330?????
Walter 12/23/2008 3:06:00 AM
Thanks! That took care of it.
--
Thanks for your help!
Walter


"tkelley via AccessMonster.com" wrote:

[Quoted Text]
> Agreed. Except I'd use:
>
> Dim varPrevOdometer As Long
>
> In over ten years, I've seen very few actual reasons to use a variant.
>
>
> Tony wrote:
> >try this:
> >
> >Dim varPrevOdometer As Integer
> >
> >> This is the code that for some reason isn't following standard mathematical
> >> logic. In my current record, Me.Odometer = 869343. The last Odometer
> >[quoted text clipped - 27 lines]
> >>
> >> End Sub
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1
>
>
Re: How is 869343 less than 869330?????
"Tony Toews [MVP]" <ttoews[ at ]telusplanet.net> 12/25/2008 10:53:23 PM
Tony <Tony[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>Dim varPrevOdometer As Integer

Just to follow up on this an Integer field is too small to use for an
odometer reading.

From A97 help "Integer stores numbers from –32,768 to 32,767 (no
fractions)"

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Re: How is 869343 less than 869330?????
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> 12/26/2008 2:06:00 AM
[Quoted Text]
>From A97 help "Integer stores numbers from –32,768 to 32,767 (no
>fractions)"

Does A97 Help really say that? In every other version its -32,768 to 32,767!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

Re: How is 869343 less than 869330?????
"Tony Toews [MVP]" <ttoews[ at ]telusplanet.net> 12/26/2008 5:10:31 AM
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> wrote:

[Quoted Text]
>>From A97 help "Integer stores numbers from ?32,768 to 32,767 (no
>>fractions)"
>
>Does A97 Help really say that? In every other version its -32,768 to 32,767!

You mean the question mark instead of the minus sign? That's
something weird going on with the copy and paste from A97 help and
your news reader. In your news reader headers I see
Content-Type: text/plain; charset="utf-8"
but mine shows
Content-Type: text/plain; charset=ISO-8859-1 .
What that means I haven't a clue.

Trust me, I would *not* retype that. <smile>

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Re: How is 869343 less than 869330?????
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/26/2008 1:34:44 PM
For what it's worth, I saw Tony's post as saying -32,768 to 32,767

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Tony Toews [MVP]" <ttoews[ at ]telusplanet.net> wrote in message
news:flp8l4l1sij7dgcosljjvusooodl7n14ea[ at ]4ax.com...
[Quoted Text]
> "Linq Adams via AccessMonster.com" <u28780[ at ]uwe> wrote:
>
>>>From A97 help "Integer stores numbers from ?32,768 to 32,767 (no
>>>fractions)"
>>
>>Does A97 Help really say that? In every other version its -32,768 to
>>32,767!
>
> You mean the question mark instead of the minus sign? That's
> something weird going on with the copy and paste from A97 help and
> your news reader. In your news reader headers I see
> Content-Type: text/plain; charset="utf-8"
> but mine shows
> Content-Type: text/plain; charset=ISO-8859-1 .
> What that means I haven't a clue.
>
> Trust me, I would *not* retype that. <smile>
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Please respond only in the newsgroups so that others can
> read the entire thread of messages.
> Microsoft Access Links, Hints, Tips & Accounting Systems at
> http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/


Re: How is 869343 less than 869330?????
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> 12/26/2008 1:48:17 PM
You mean Access isn't the only quirky software?

;0)>

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

Re: How is 869343 less than 869330?????
"Tony Toews [MVP]" <ttoews[ at ]telusplanet.net> 12/26/2008 9:16:40 PM
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> wrote:

[Quoted Text]
>You mean Access isn't the only quirky software?
>
>;0)>

Hehehehe

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net