473,569 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sometimes, top-values query does not return top-most value ???

MLH
Have a data entry form bound to a table.
Has a save button on it that launches DoCmd.RunComman d acCmdSaveRecord
in Access 97. In the form after-update code, I have a line looking
something like this:

LastVehicleJobI D = DLookup("[VehicleJobID]", "qryGetLastVehi cleJobID")

qryGetLastVehic leJobID looks something like this:
SELECT TOP 1 tblVehicleJobs. VehicleJobID
FROM tblVehicleJobs
ORDER BY tblVehicleJobs. VehicleJobID DESC;

Immediately after the RunCommand acCmdSaveRecord line,
sometimes the value returned by the top values query is the
ID of not the newly added record, but the one before it. Not all
the time does this happen. But sometimes it happens. Is that
normal? I do not have a DoEvents line after the acCmdSaveRecord
line. Should I have to? Previously, I've been under the impression
that Form AfterUpdate code did not run until the write to the table
had been made and was finished. Is that the way it's supposed to be?
Apr 8 '07 #1
2 2107
It should work if the data is in an Access table (not something linked to a
different database program.)

Instead of the RunCommand, try:
Me.Dirty = False
That should notify you if the record did not save.

Some other cases where it might not work include:
- Existing record (so the entry is not the last one.)
- New record not dirtied (so the last one doesn't match.)
- AutoNumber is Random instead of Incremental.
- Seed of AutoNumber has been reset (usually bug.)
- Another user saved another record since (rare.)

Is there any reason you are looking in the table instead of reading the
value from the form itself? (Access 97 can report the wrong number in
Form_AfterUpdat e, and rarely in Form_ BeforeUpdate too, so perhaps you are
trying to avoid this.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthStat e.netwrote in message
news:jj******** *************** *********@4ax.c om...
Have a data entry form bound to a table.
Has a save button on it that launches DoCmd.RunComman d acCmdSaveRecord
in Access 97. In the form after-update code, I have a line looking
something like this:

LastVehicleJobI D = DLookup("[VehicleJobID]", "qryGetLastVehi cleJobID")

qryGetLastVehic leJobID looks something like this:
SELECT TOP 1 tblVehicleJobs. VehicleJobID
FROM tblVehicleJobs
ORDER BY tblVehicleJobs. VehicleJobID DESC;

Immediately after the RunCommand acCmdSaveRecord line,
sometimes the value returned by the top values query is the
ID of not the newly added record, but the one before it. Not all
the time does this happen. But sometimes it happens. Is that
normal? I do not have a DoEvents line after the acCmdSaveRecord
line. Should I have to? Previously, I've been under the impression
that Form AfterUpdate code did not run until the write to the table
had been made and was finished. Is that the way it's supposed to be?
Apr 8 '07 #2
MLH
On Sun, 8 Apr 2007 17:35:40 +0800, "Allen Browne"
<Al*********@Se eSig.Invalidwro te:
>Is there any reason you are looking in the table instead of reading the
value from the form itself? (Access 97 can report the wrong number in
Form_AfterUpda te, and rarely in Form_ BeforeUpdate too, so perhaps you are
trying to avoid this.)
As a matter of fact, I haven't a good reason for reading the table
value instead of reading the AutoNumber field value right off the
form itself. I'm going to start doing just that. None of the other
conditions you pointed out are applicable. Its as if a race condition
exists in the process and the winner is the process trying to read
the new record and the loser is the process writing the new record.
At this point, I don't give a flying shit about the WHY? I'll settle
for the right value - and that will appear in the VehicleJobID field
on the form EVERY time. That much is for certain. Up until yesterday,
I did not have the VehicleJobID field on the data entry form - since
it was not a field that I thought necessary. Big wake up call - here's
a perfectly good reason for it.

Whenever this problem occurred, I've gone back to MAKE SURE THE
NEW RECORD WAS WRITTEN. It was - every single time. For two years,
the procedure in the AfterUpdate code has been reading the new record
ID field value from the table. 99% of the time, it snatches the value
of the NEW record. Every now and then, though, it gets the value of
the last record BEFORE the newly added record is written. I know it
immediately when it happens because letters that should-a-been printed
do not get printed and I find myself going Duhhhhh??????

At first, I was planning on reading the keyfield value of the last
rec in table BEFORE appending a new record, reading it again AFTER
appending the new record and comparing the values to LOOK for this
anomoly. But who the fuck cares about "catching it in the act" of
being wrong. Its too fuckin' late then. I think its a built-in
Micro$oft fuck-up - you know, shit happens. I'd rather have a work-
a-round tthat circumvents the problem than to have the problem and
go "Whoopee! I found it!" I appreciate the feedback.
Apr 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4516
by: Stephane Dalpe | last post by:
Hi all, I just want to know why when I'm installing jdk sometimes ask me to reboot and sometimes he don't. As part of our installation, we launch the jdk installation if it's not already installed, so it's important to know when the user will be asked to reboot. Thanks
2
1539
by: Werner Partner | last post by:
I'm a little confused: htmled phase5 uses this Date-Tag: <!--DATE-->28.03.2004<!--/DATE--> If I try to validate the source, sometimes I get an error, sometimes not. This source: http://www.sonoptikon.de/akkordeon/assahra.html
6
1803
by: Ron Brennan | last post by:
Good evening. An HTML problem maybe, but one that I think can be solved with JavaScript. I have a page which is supposed to display several small JPEG images using elements like: <image src="SmallImages/image1.jpeg" height="40" width="30"></image> The image files are fine - I can open them reliably by double clicking in
6
5967
by: Dot net work | last post by:
I've read quite a few threads on these groups about this. When someone says the following: "My Page_Load gets called twice on a button click postback" The replies are: "Do you have AutoEventWireup=True in your page header?" In my project, I have this set to false - everywhere.
1
1159
by: Jeffrey Frabutt | last post by:
Hey... I'm reletively new to ASP.NET and am having some frustrating debugging issues. Everything is configured correctly for me to debug my VERY simple one-page application. That said, after just one or two start/debug/stop cylces of my project, it suddenly hangs... and I cannont debug. Sometimes I can fix it by stopping and restarting IIS,...
7
1458
by: jw | last post by:
//it sometimes crashes sometimes not why? #include<iostream> #include<fstream> #include<vector> #include<string> #include<ctime> using namespace std; #ifndef NULL #define NULL (short) 0 #endif
2
1849
by: cheers_ye | last post by:
The source of the image is <IMG ID=\"69\" class=\"a10\"...
5
2792
by: David Thielen | last post by:
Hi; We have our app up on a beta server. Sometimes people from outside the firewall get "The page cannot be displayed" when they try to access it. A couple of weird things about this: 1) If someone inside the firewall accesses it, that always works. 2) If someone inside the firewall accesses it, then the person outside can access it....
0
1261
by: comp.lang.php | last post by:
<? header('Pragma: no-cache'); // ENSURE CLIENT-SIDE CACHE FLUSHING $url = "$projectURLPath/index.php"; if ($_REQUEST) $url .= '?logoutMsg='. urlencode($_REQUEST); if ($willAuthenticate && $willUseSSL) { $dest = 'https://' . $_SERVER . $url; } elseif ($willBasicAuthenticate && $willUseSSL) { $dest =...
0
823
by: radiv | last post by:
My code is in ASP.Net. I have loaded a web page into a web browser and have identified the elements on the web page (buttons) using Ihtmldocument and have my code written to the events. HTMLInputElement ReadyButton = (HTMLInputElement)PhoneControlsDocument.all.item("ReadyButton", null); ...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.