Results 1 to 4 of 4

Thread: very simple---->Next Record Problem

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Location
    Pakistan
    Posts
    28

    Unhappy very simple---->Next Record Problem

    HI


    I have a connection Mudule

    Public con As New ADODB.Connection
    Public rec As New ADODB.Recordset
    Sub main()
    On Error GoTo hell
    Set con = New ADODB.Connection
    Set rec = New ADODB.Recordset
    con.Open "Provider = Microsoft.Jet.Oledb.4.0; Data Source=" & App.Path & "\Revise.mdb"
    rec.Open "Select * from Revise", con, 2, 3
    rec.MoveFirst
    Call fill
    Form1.Show
    hell:
    If Err.Number <> 0 Then
    MsgBox "Connection problem" & vbCrLf & vbCrLf & Err.Description, vbCritical, "Ahan"
    End If
    End Sub
    Function fill()
    With rec
    Form1.txtroll.Text = .Fields(0)
    Form1.txtname.Text = .Fields(1)
    Form1.txtcrs.Text = .Fields(2)
    Form1.txtmark.Text = .Fields(3)
    End With
    End Function
    Function blank()
    Form1.txtroll.Text = ""
    Form1.txtname.Text = ""
    Form1.txtcrs.Text = ""
    Form1.txtmark.Text = ""
    End Function
    Function check()
    If Form1.txtroll.Text = "" Then
    MsgBox "Please enter RollNo", vbCritical
    Else
    If Form1.txtname.Text = "" Then
    MsgBox "Please enter Name", vbCritical
    Else
    If Form1.txtcrs.Text = "" Then
    MsgBox "Please enter Course Title", vbCritical
    Else
    If Form1.txtmark.Text = "" Then
    MsgBox "Please enter Marks", vbCritical
    End If
    End If
    End If
    End If
    End Function

    and the problem is with my next record

    plese can u provide me the code for next record with the message "u are already at last record"
    or
    correct this code

    Private Sub cmdnext_Click()
    On Error GoTo hell
    If rec.State = adStateOpen Then
    rec.Close
    End If
    rec.Open "select * from Revise", con, 2, 3
    rec.MoveNext
    Call fill
    hell:
    If Err.Number <> 0 Then
    MsgBox "Error in Syntax" & vbCrLf & vbCrLf & Err.Description, vbCritical, "Ahan"
    End If
    End Sub

    this code returns only one next record
    i hope u will help me
    i also attach my file

    Thanx in advance 4 help
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width