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

No Current Record???

I don't understand why I am getting the error message "No current record" at my code....Do While rs1!Symbol = rs2!Symbol....it seems that rs1 has values, but rs2 is empty. Any help? Many thanks!!

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbFindLastEssentialData_Click()
  2.  '  On Error GoTo Exit_MyProc
  3.  
  4.    DoCmd.RunSQL "DELETE * FROM LastGoodData;"
  5.  
  6.     strSQL = "SELECT DailyPrice.Symbol, DailyPrice.LocateDate, DailyPrice.MarketPrice " & _
  7.         "FROM DailyPrice, TempSymbol " & _
  8.         "WHERE (((DailyPrice.Symbol) = [TempSymbol]![Symbol])) " & _
  9.         "ORDER BY DailyPrice.Symbol, DailyPrice.LocateDate DESC;"
  10.  
  11.     strSQLTEMP = "SELECT TempSymbol.Symbol" & _
  12.                             " FROM TempSymbol" & _
  13.                             " WHERE (((TempSymbol.Symbol) Is Not Null))" & _
  14.                             " ORDER BY TempSymbol.Symbol;"
  15. Debug.Print strSQLTEMP
  16.     Set db = CurrentDb
  17.     Set rs1 = db.OpenRecordset(strSQL)
  18.     Set rs2 = db.OpenRecordset(strSQLTEMP)
  19.  
  20.     rs2.MoveFirst
  21.  
  22.     rs1.MoveFirst
  23.     Debug.Print rs1!Symbol & " " & rs2!Symbol
  24.     Do Until rs1.EOF
  25.         Do While rs1!Symbol = rs2!Symbol
  26.             If rs1!MarketPrice <> -(mLSGC) Or -5.25 Then
  27.                 Debug.Print rs1!LocateDate, rs1!Symbol, rs1!MarketPrice
  28.                 strINSERT = "INSERT INTO LastGoodData (LocateDate, Symbol, MarketPrice) VALUES (#" & rs1!LocateDate & "#, '" & rs1!Symbol & "', " & rs1!MarketPrice & ");"
  29.                 Debug.Print strINSERT
  30.                 db.Execute strINSERT, dbFailOnError
  31.                 Exit Do
  32.             Else    'only for -5.25 data
  33.             Debug.Print "I'm here"
  34.                 rs1.MoveNext
  35.                 If rs1!Symbol <> rs2!Symbol Then
  36.                     strINSERT = "INSERT INTO LastGoodData (LocateDate, Symbol, MarketPrice) VALUES (#" & rs1!LocateDate & "#, '" & rs1!Symbol & "', " & rs1!MarketPrice & ");"
  37.                     Debug.Print strINSERT
  38.                     db.Execute strINSERT, dbFailOnError
  39.                     Exit Do
  40.                 ElseIf rs1.EOF Then
  41.                     MsgBox "rs1 eof"
  42.                     strINSERT = "INSERT INTO LastGoodData (LocateDate, Symbol, MarketPrice) VALUES (#" & rs1!LocateDate & "#, '" & rs1!Symbol & "', " & rs1!MarketPrice & ");"
  43.                     Debug.Print strINSERT
  44.                     db.Execute strINSERT, dbFailOnError
  45.                     Exit Do
  46.                 End If
  47.  
  48.             End If
  49.         Loop
  50.         rs2.MoveNext
  51.     Loop
  52.     '    rs2.MoveNext
  53.     '    If Not rs2.EOF Then
  54.     '        Debug.Print rs2!Symbol
  55.     '    End If
  56.     'Loop
  57.     MsgBox "Table updated successfully"
  58.  
  59.     rs1.Close
  60.     rs2.Close
  61.     Set rs1 = Nothing
  62.     Set rs2 = Nothing
  63.     Set db = Nothing
  64.  
  65. End Sub
Jan 29 '07 #1
3 2801
NeoPa
32,556 Expert Mod 16PB
You do an rs2.MoveNext at the end of your Do Loop but don't ever seem to check for rs2.EOF. I expect this would cause you to hit that error.
Jan 29 '07 #2
NeoPa
32,556 Expert Mod 16PB
In future, please do some trimming work before requesting debugging help.
You should be looking to test code which has all the lines stripped out which are not relevant to the error. When this has been done then post this stripped down version (that still exhibits the problem in the same way) in your question. This will help you find the problem and also save time for our experts going through irrelevant lines of code.

MODERATOR.

As an illustration (It's not enormously shorter, but does save some time going through)
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbFindLastEssentialData_Click()
  2.  
  3.     strSQL = "SELECT DailyPrice.Symbol, DailyPrice.LocateDate, DailyPrice.MarketPrice " & _
  4.         "FROM DailyPrice, TempSymbol " & _
  5.         "WHERE (((DailyPrice.Symbol) = [TempSymbol]![Symbol])) " & _
  6.         "ORDER BY DailyPrice.Symbol, DailyPrice.LocateDate DESC;"
  7.  
  8.     strSQLTEMP = "SELECT TempSymbol.Symbol" & _
  9.                             " FROM TempSymbol" & _
  10.                             " WHERE (((TempSymbol.Symbol) Is Not Null))" & _
  11.                             " ORDER BY TempSymbol.Symbol;"
  12.     Set db = CurrentDb
  13.     Set rs1 = db.OpenRecordset(strSQL)
  14.     Set rs2 = db.OpenRecordset(strSQLTEMP)
  15.  
  16.     rs2.MoveFirst
  17.  
  18.     rs1.MoveFirst
  19.     Do Until rs1.EOF
  20.         Do While rs1!Symbol = rs2!Symbol
  21.             If rs1!MarketPrice <> -(mLSGC) Or -5.25 Then
  22.                 strINSERT = "INSERT INTO LastGoodData (LocateDate, Symbol, MarketPrice) VALUES (#" & rs1!LocateDate & "#, '" & rs1!Symbol & "', " & rs1!MarketPrice & ");"
  23.                 db.Execute strINSERT, dbFailOnError
  24.                 Exit Do
  25.             Else    'only for -5.25 data
  26.                 rs1.MoveNext
  27.                 If rs1!Symbol <> rs2!Symbol Then
  28.                     strINSERT = "INSERT INTO LastGoodData (LocateDate, Symbol, MarketPrice) VALUES (#" & rs1!LocateDate & "#, '" & rs1!Symbol & "', " & rs1!MarketPrice & ");"
  29.                     db.Execute strINSERT, dbFailOnError
  30.                     Exit Do
  31.                 ElseIf rs1.EOF Then
  32.                     strINSERT = "INSERT INTO LastGoodData (LocateDate, Symbol, MarketPrice) VALUES (#" & rs1!LocateDate & "#, '" & rs1!Symbol & "', " & rs1!MarketPrice & ");"
  33.                     db.Execute strINSERT, dbFailOnError
  34.                     Exit Do
  35.                 End If
  36.             End If
  37.         Loop
  38.         rs2.MoveNext
  39.     Loop
  40. End Sub
Jan 29 '07 #3
NeoPa
32,556 Expert Mod 16PB
Another problem with your code - related or unrelated to your current issue I don't know - is :
Expand|Select|Wrap|Line Numbers
  1. If rs1!MarketPrice <> -(mLSGC) Or -5.25 Then
This will always be TRUE as the value -5.25 is non-zero. It is not being compared to anything so returns the value directly.
Jan 29 '07 #4

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

Similar topics

1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and 5)record number. If the foreign content (FC)is >15% of...
2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a field in the subform and using run command...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
5
by: christianlott1 | last post by:
I admit my form is pretty complex and may need a total overhaul - I have two subforms synchronized on a form through an unbound text box. When I enter a new record in the second subform it used...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several thousand inventory items. The user can enter a...
6
by: MLH | last post by:
Cut this little FN out-a-Access 97 HELP. It makes mention of the new record being made the current record. Is it the Update method responsible for that - or the Bookmark method? Which one? ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.