Hi,
In .NET i used the follwing codings for the Next and Previous buttons for Navigating the records. but it showed error. In NextButton_Click...

[dim Rec_count = 0] -> this is globally declared.
[dim Row_count as Integer = Data.Tables(0).Rows.Count - 1]
[ If Rec_count <> Row_count Then]
[ Rec_count = Rec_count + 1]
[ TextBox1.Text = Data.Tables(0).Rows(Rec_count).item(0) ]
[ TextBox1.Text = Data.Tables(0).Rows(Rec_count).item(1) ]
[ TextBox3.Text = Data.Tables(0).Rows(Rec_count).item(2) ]
[ Else ]
[ MsgBox " This is last record " ]

So by writing coding like this, for the first time it goes to next record, but if i again click the next button, it doesnt go. it just shows the same record.
So only once it goes to the next record.
same coding for Previous Button also. Only one change is ...

[ Rec_count = Rec_count - 1 ]

. So can anyone help me for the navigation codings??

'Variables
    Dim rowNum As Integer = 0
    Dim dbMaxNumRows As Integer = dbDataSet.Tables("Dataset").Rows.Count - 1

    'Moves forward a record
    Private Sub btNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btNext.Click
        'If the current row number doesn't not equal the max number of rows
        If rowNum <> dbMaxNumRows Then
            'add one onto the row number
            rowNum = rowNum + 1
            'Fill in all the relevent fields
            Field1.Text = dbDataSet.Tables("Dataset").Rows(rowNum).Item("Var1")
            Field2.Text = dbDataSet.Tables("Dataset").Rows(rowNum).Item("Var2")
            Field3.Text = dbDataSet.Tables("Dataset").Rows(rowNum).Item("Var3")
        Else
            'Else if the row number does equal the maximum number of fields
            'Go to the first record, a loop hey? :)
            rowNum = 0
            'Fill in all the needed fields
            Field1.Text = dbDataSet.Tables("Dataset").Rows(rowNum).Item("Var1")
            Field2.Text = dbDataSet.Tables("Dataset").Rows(rowNum).Item("Var2")
            Field3.Text = dbDataSet.Tables("Dataset").Rows(rowNum).Item("Var3")
        End If
    End Sub

Although slightly different as far as I'm aware of this works. I've watered this version down a bit from the one I've used to make it clearer. In this version it loops instead of just ending, but you can change this. I'm not sure where you went wrong though. But if anyone can compare them and point it out that'd be good. I hope this helps, I'm hoping this works to as I've not tested it since I've removed and changed stuff from what it originally was.

I think it is a better option to use a binding source to solve your problem.

You can attach data to a component using the following-

dim ds as new dataset
dim bs as new bindingsource(ds,"<table name>")

me.textbox1.databindings.add("Text",bs,"<field name>")

Next button- bs.Movenext()

Previous- bs.MovePrevious()

I have creat one project in there one customer_form & supplier_form
i want to showing record to using to next button
if we click next button then show next record
i dn't know code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.