473,322 Members | 1,307 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,322 software developers and data experts.

Looping through recordset only returns first record each time - not the next an so on

Here is the problematic code:
Expand|Select|Wrap|Line Numbers
  1. Dim rst1 As DAO.Recordset
  2. Set rst1 = CurrentDb.OpenRecordset("SETimes", dbOpenDynaset)
  3.     With rst1
  4.         Do While Not .EOF
  5.         CurSDate = rst.Fields("STimes").Valuet
  6.         MsgBox(CurSDate)
  7.         CurSDateUK = CurSDate
  8.         CurSDateV = DateAdd("s", -60, CurSDateUK)
  9.         CurSDateVF = Format(Left([CurSDateV], 10), "yyyy-mm-dd")
  10.         CurSTimeVF = Right(CurSDateV, 8)
  11.         CurSDateV = CurSDateVF & " " & CurSTimeVF
  12.         CurFSDate = Format(Left(CurSDate, 10), "yyyy-mm-dd")
  13.         CurFSTime = Right(CurSDate, 8)
  14.         CurSDate = CurFSDate & " " & CurFSTime
  15.         CurEDate = rst.Fields("ETimes").Value
  16.         CurEDateUK = CurEDate
  17.         CurFEDate = Format(Left(CurEDate, 10), "yyyy-mm-dd")
  18.         CurFETime = Right(CurEDate, 8)
  19.         CurEDate = CurFEDate & " " & CurFETime
  20.  
So basically, I have a table SETimes, which contains (this varies) but around 13 start dates and 13 end dates.
The previous loop I have in the code above this section works fine, but with this, it loops through until it reaches the end of the recordset (13 loops), but defines the 'CurSDate' variable as being the first record each time. I added a message box to demonstrate this, but I do not understand what is going on here. The table which the recordset opens has 13 different dates, each on their own numbered row - plus the same code seems to work earlier in the sequence.
Am I missing something here?

Thanks in advance,
-Craig
Dec 13 '11 #1

✓ answered by ADezii

  1. Is the following a Typo?
    Expand|Select|Wrap|Line Numbers
    1. CurSDate = rst.Fields("STimes").Valuet 
  2. Your Code is cut off, but I do not see an explicit .MoveNext in order to advance through the Loop.

2 2046
ADezii
8,834 Expert 8TB
  1. Is the following a Typo?
    Expand|Select|Wrap|Line Numbers
    1. CurSDate = rst.Fields("STimes").Valuet 
  2. Your Code is cut off, but I do not see an explicit .MoveNext in order to advance through the Loop.
Dec 13 '11 #2
Yes it was a typo, and also I was referencing rst for the record source variable instead of rst2!
Thanks for the help bro!
-Craig
Dec 13 '11 #3

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

Similar topics

0
by: Stephen Yeargin | last post by:
If I've got: Table: users ID USERNAME EMAIL 1 syeargin stephen@yeargin.com 2 bwalkerton benwalkerton@aol.com 3 rrandall rr@aol.com .... Table: committees
3
by: Bryan Harrington | last post by:
I have a list of requests that I'm displaying. The client wants to be able to display the details of the FIRST request as the page loads. Right now, as I loop through the recordset, I'm checking...
3
by: Jason A. Thompson | last post by:
Dear Access Gurus, I have a database which I hoped to use to administer questionnaires, or rather that someone who knows nothing about Access could use to administer them. Each q'aire item is on...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
2
by: Anand Ganesh | last post by:
Hi All, How to Implement Move Next, Move Previous, Last Record and First Record in a DataGrid Control ? Is there any standard tool available in the tool box button? Thanks for your time. ...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
0
by: hagar | last post by:
Hi all, I have a problem which I can not understand why this is happening! Debugging this I actually see that it grabs first record then when stepping through code to the line rsImportTo.AddNew...
6
by: zack | last post by:
This query has been driving me crazy, and would be grateful for a nudge in the right direction. Still pretty much a beginner using Access 2003, I just cannot figure the solution to the following in...
16
by: haft | last post by:
I have posted this question on a javascript forum as it contains javascript code however it was believed to be an asp issue. The following head section javascript code contains the function...
3
by: isak | last post by:
I have a webpage that lists the results of a preliminary database search -- (http://www.txlivingus.com/ourListings.php, then click on"non-mls listings." Each item on the list links to a detail page...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.