"No current record" error merssage

After deleting all records in a .mdb database, I get a no current record error message when I try to add a new record.
edmacAsked:
Who is Participating?
 
AnswerTheManConnect With a Mentor Commented:
something id wrong with your CODE. try :


Private Sub Command1_Click()
       Dim MyData As Database
       Set MyData = OpenDatabase("FilePath",False,False)        
       Dim MyRec As Recordset
       Set MyRec =MyData.OpenRecordset("tblExample",dbOpenTable)
       With MyRec
             Do While .EOF = False
                     .Delete
                     .MoveNext
             Loop
             .AddNew
             .Fields("fldExample1") = "MyValue"
             .Fields("fldExample2") = "YourValue"
             .Update
             .Close
        End With
        MyData.Close
End Sub


0
 
chewhoungCommented:
Try Refresh the data control after delete.
eg:
Data1.refresh

0
 
CraigLazarCommented:
trap the error vb returns and assign your field names null values until there is a new record in the datagbase , then go data1.refresh
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.