Question:

Can some help with this problem in VB6?

by  |  earlier

0 LIKES UnLike

can some help with this problem in VB6?

why when i kip pressing next there i and error this is the code plz help me

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

Dim DB As Database

Dim RS As Recordset

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

End Sub

Private Sub cmdprev_Click()

RS.MovePrevious

Text1.Text = RS!Name

Text2.Text = RS!Course

Text3.Text = RS!Address

End Sub

Private Sub cmdsave_Click()

Dim DB As Database

Dim RS As Recordset

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

--------------------------------------...

some code is still missing i don't know who i can fix it,,,,

i need when i press next and go to the last list it go again in the first list tnx

 Tags:

   Report

4 ANSWERS


  1. Project and programming help-http://javahelper.info/


  2. ASP.NET Interview Question And Answers-http://aspdotnetanswers.blogspot.com/

  3. what is it meant to do?

  4. it is because you never check the position of the recordset.

    you keep pressing next button and it will result in error because the recordset is already at the last record AKA (End Of File). same thing happens when you keep pressing the previous button.

    you need to check it first before doing the movenext/moveprevious.

    Use.

    for next button :

    If RS.EOF then

      msgbox("you reached then end of record")

    else

      -- your code

    end if

    and use RS.BOF for previous button

    hope that can help.

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.