Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUN TIME ERROR 3021 NO CURRENT RECORD 1

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
I am getting the above error on this code. there is data on my table.

It stops on the following line
Do Until Not IsNull(rstpno!pno) And rstpno.EOF = True


Private Sub Command0_Click()
Dim dbs As Database, rstpno As Recordset
Set dbs = CurrentDb
Set rstpno = dbs.OpenRecordset("table1", dbOpenDynaset)
DoCmd.SetWarnings False
' DoCmd.Echo False
rstpno.MoveLast

MsgBox rstpno.RecordCount
rstpno.MoveFirst


Do Until Not IsNull(rstpno!pno) And rstpno.EOF = True

DoCmd.OpenQuery "getpno", acViewNormal
DoCmd.OpenQuery "updpno", acViewNormal
rstpno.MoveNext

Loop

rstpno.Close
Set dbs = Nothing
DoCmd.SetWarnings True
' DoCmd.Echo True villica
 
I would suggest that you put a stop in the code and step through the code to verify that you have an openrecordset with records available. When you get to the rstpno.MoveFirst go to the debug window and enter ?rstpno("fieldname") and see if it returns data. Let's make sure that what you are saying about data in your table is being opened by the OpenRecordset command. Bob Scriver
 
Both conditions need to be true to leave the loop. simplfy the loop condition. You have probably hit EOF but the not isnull has not been met.


Do Until Not IsNull(rstpno!pno) And rstpno.EOF = True

DoCmd.OpenQuery "getpno", acViewNormal
DoCmd.OpenQuery "updpno", acViewNormal
rstpno.MoveNext

Loop


 

while Not rstpno.EOF = True
If IsNull(rstpno!pno) then exit while

DoCmd.OpenQuery "getpno", acViewNormal
DoCmd.OpenQuery "updpno", acViewNormal
rstpno.MoveNext

Wend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top