it always say "no current record" when i get to the last record
Option Explicit
Dim DB As Database
Dim RS As Recordset
Private Sub Command4_Click()
End
End Sub
Private Sub cmdadd_Click()
cmdsave.Visible = True
cmdcancel.Visible = True
cmdadd.Visible = False
cmdprev.Visible = False
cmdnext.Visible = False
cmdexit.Visible = False
cmdfirst.Visible = False
cmdlast.Visible = False
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub cmdcancel_Click()
cmdsave.Visible = False
cmdcancel.Visible = False
cmdadd.Visible = True
cmdprev.Visible = True
cmdnext.Visible = True
cmdexit.Visible = True
cmdfirst.Visible = True
cmdlast.Visible = True
Set DB = OpenDatabase(App.Path & "/db1.mdb")
Set RS = DB.OpenRecordset("STUD_INFO")
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
End Sub
Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdfirst_Click()
RS.MoveFirst
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
End Sub
Private Sub cmdlast_Click()
RS.MoveLast
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
End Sub
Private Sub cmdnext_Click()
RS.MoveNext
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
If RS.EOF = True Then
RS.MoveFirst
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
End If
End Sub
Private Sub cmdprev_Click()
RS.MovePrevious
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
If RS.BOF = True Then
RS.MoveLast
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
End If
End Sub
Private Sub cmdsave_Click()
Set DB = OpenDatabase(App.Path & "/db1.mdb")
Set RS = DB.OpenRecordset("STUD_INFO")
RS.AddNew
RS!Name = Text1.Text
RS!Course = Text2.Text
RS!address = Text3.Text
RS.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
MsgBox "DATA SAVED", vbOKOnly, "app Message"
End Sub
Private Sub Form_Load()
cmdsave.Visible = False
cmdcancel.Visible = False
Set DB = OpenDatabase(App.Path & "/db1.mdb")
Set RS = DB.OpenRecordset("STUD_INFO")
Text1.Text = RS!Name
Text2.Text = RS!Course
Text3.Text = RS!address
End Sub
can someone fix it for me tnx
Tags: