-Collapse +Expand
Access
Search Access Group:

Advanced
Access To/From
To/FromCODEGuides
Access Store
PRESTWOODSTORE

Prestwood eMagazine

July Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyMicrosoft Access BoardAccess VBA Programming Topic   Print This     

Sparatic Query Behaviour

Sparatic Query Behaviour in Access VBA Programming topic (part of our Microsoft Access group).

Quick Search: Sparatic   Behaviour   Sparatic Query   Sparatic Query Behaviour  
Most Recent Post
ScottCybak
 (Inactive)
Windsor, Ontario, Canada
Having problems with the behaviour of this code:


Dim lngMaxRec As Long

'find max record number in series lower then current value, assign 0 if none exists
lngMaxRec = Nz(DMax("[OdoNum]", "tblOdo", "[RecNum] = " & Me![RecNum] & " AND [OdoNum] < " & Me![OdoNum]), 0)
'assign current ending (defualt value)
Me![EndOdo] = Me![BegOdo]

If Not (lngMaxRec = 0) Then
'if not the first record in series
DoCmd.SetWarnings (False)
DoCmd.RunSQL ("UPDATE tblOdo SET EndOdo = " Me![BegOdo] & " WHERE OdoNum = " & lngMaxRec & "")
MsgBox "UPDATE tblOdo SET EndOdo = " Me![BegOdo] & " WHERE OdoNum = " & lngMaxRec & ""
DoCmd.SetWarnings (True)
End If

It will work fine, on the first record in the subform.. it will work fine, for the 2nd, 3rd.. etc.. problem is, say i enter a whole bunch of values in another field in the table (state codes) before i start punching in the odometer readings.. then, i go back and update the BegOdo field

the msgbox pops up, as it should, cept, the query never runs.. the message box values are right on the mark, which is giving the probs. If the message box is giving the same values the update query uses, should the update query not work????? it should in my opinion.. but doesn't for some reason

the code is in the 'afterupdate' event of my BegOdo field..

P.s. I know i'm breaking the rules of Norm, it was my only solution.. so please, no comments on why i'm storing a field value in 2 records.

Thanks in advance for anything you can offer!

Yours Truly,


 Posted 25 years ago (Thread Starter)
Comment Quote
About ScottCybak
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2014, No Replies Be the first!
Thread Started 5/4/2001 5:50:00 PM
View Counter=1937
Last Reply Posted 2/19/2017 11:47:21 PM)
Location=Windsor, Ontario, Canada  
Joined=25 years ago   MB Posts=64  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1165A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #2014 Counter
1937
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2026 Prestwood IT Solutions.   [Security & Privacy]