473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Do Until Loop crashed Access

294 256MB
I'm attempting to update a field in the table from the Max Date field in another table using VBA code. I attempted to simply use an Update query, however, I read that JET won't allow my query that gets the Max date to be utilized in an Update query. Hence, this is the solution I came up with.

When I try to run it to test the data, it only updated the first row, then crashed Access. Any ideas?

Expand|Select|Wrap|Line Numbers
  1.             Set db = CurrentDb
  2.             Set rs = db.OpenRecordset("SELECT * FROM PayrollRequestTbl")
  3.  
  4.             If rs.BOF And rs.EOF Then
  5.             Else
  6.             Do Until rs.EOF
  7.                 navDate = rs!MCR_RecentNAV
  8.                 navDate = DMax("NAV_Date", "NAV_Tbl")
  9.  
  10.                 rs.Edit
  11.                 rs!MCR_RecentNAV = navDate
  12.                 rs.Update
  13.             Loop
  14.             rs.Close
  15.             Set rs = Nothing
Dec 16 '13 #1
6 1503
zmbd
5,501 Expert Mod 4TB
Take a careful look at your loop....
you never move to the next record.
Dec 16 '13 #2
Jim Doherty
897 Expert 512MB
Your code is staying on the first line of your recordset and remaining in an infinite loop

you need to insert.....

rs.MoveNext

as a line before the LOOP command so that the recordset can be traversed. At the moment it is not doing that.
Dec 16 '13 #3
mcupito
294 256MB
That's it! I wasn't sure if I needed the rs.MoveNext or not. Thanks, all!
Dec 16 '13 #4
Rabbit
12,516 Expert Mod 8TB
You should be able to use an update query. Have you tried it?
Dec 16 '13 #5
mcupito
294 256MB
Hey, Rabbit. I did try. It wouldn't let me because I needed to bring in a query that get the Max(Date) field, which apparently isn't supported by JET.
Dec 17 '13 #6
Rabbit
12,516 Expert Mod 8TB
Can you post the SQL you tried?
Dec 17 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Eric | last post by:
Let me start off by saying I have VB working model which means no help. I have searched MSDN. It seems that I get "Read the help" instead of answers which is totally useless to me. With that...
4
by: .Net Sports | last post by:
I am trying to display records from a recordset after sql statement: <% sqlstr ="SELECT horsename FROM tblhorseentry WHERE trackname = '" & request.querystring("trackname") & "' and racedate =...
2
by: MLH | last post by:
Take a look at the code that follows. Line 110 is the beginning of Do-Loop. Regarding line #220, I find that I'm getting Error #3021 (No Current Record) during execution of line #230. It puzzles me...
15
by: shannon | last post by:
Hello, I am wondering if a Do until loop can be used in Javascript. I have an array and want to fill the array 10 times with the users details until it reaches 10 or if they press cancel. I'm...
3
by: abitlikehomer | last post by:
Hi i am writing a bit of code so that the date and time of a booking can not be booked twice but i am getting an error message saying "loop without do". Any suggestions? setflag = False Do Until...
3
by: peter.meth | last post by:
Hi All, I am making a file manager type of application and am trying to duplicate Windows Explorer's behaviour when copying files; ie, display a second form with the copy files animation. As it...
4
by: Madhavi | last post by:
Hi Is there any Do Until Loop in C# Maadhavi
3
by: SyGC | last post by:
Hi People, Im trying to do a simple Loop where by an IP address is pinged (Using My.computer.network.ping) and the results, true or false, are used to invoke another line of code. Basically if...
2
by: Constantine AI | last post by:
Hello, i am wanting a Loop procedure to check details of all the multiple rows with the following D-LOOKUP procedures; StkID.Value = DLookup("", "stkmas", " = Forms!!") Price.Value = DLookup("",...
5
by: dbrother | last post by:
Access 2003 Win XP Pro SP3 Using SQL /ADO Recordsets in a Do Loop Hello, I'm using a random number generator based on an integer input from a user from a form that will get X number of random...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.