Recordset does not move to last record when requested

Robert M

Registered User.
Local time
Yesterday, 16:44
Joined
Jun 25, 2009
Messages
153
I have a program that is supposed to take the new name entered into "tblNames" and copy the "RecNum" of the "tblNames" to the "RecID" number of the "qryStationsUnused_636" Recordset.

It does copy the "RecNum" to the "RecID" but to the wrong Name in the "tblNames" For some reason it is not moving to the last record of my table but instead it lands on the 3rd to last record. Below is the program that I am using.

'Set Recordset
Set RSEmp = CurrentDb.OpenRecordset("tblNames")
Set RS636 = CurrentDb.OpenRecordset("qryStationsUnused_636")
'Match tblStations.RecID to tblName.ID
RS636.MoveFirst
RSEmp.MoveLast
MsgBox "RSEmp Name = " & RSEmp("NameF")
Do While RS636.EOF = False
If RS636("Use") = -1 Then
RS636.Edit
RS636("RecID") = RSEmp("RecNum")
RS636("Use") = 0
RS636.Update
RS636.Requery
Exit Do
End If
RS636.MoveNext
Loop

Thank you for your time and help on this matter

Robert M
 
Try changing this:
Do While RS636.EOF = False

To this:

Do Until RS636.EOF


And get rid of the RS636.Requery.
 
Thank you for your Suggestion boblarson. I did not take that route because I am not having difficulty with getting my pointers agreeing to one another. I.E. RecNum = RecID. My problem was getting the correct RecNum assigned to the RecID. I have solved this problem by changing out my RSEmp from("tblNames") to ("qryDataNames") that is a query sorted by RecNum in assending order, where the latest Name addition is on the bottom. That solved my problem of getting the correct RecNum assigned to the RecID.
Thank you for your valuable Time and Help on this problem.

Robert M
 

Users who are viewing this thread

Back
Top Bottom