Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Move to New Record

Status
Not open for further replies.

soonerman1978

Programmer
Jun 26, 2003
8
US
This is a question that has baffled me for a few days now. I have researched and come up absolutely dry. So any help would be much appreciated!!!

To start I used the data form wizard to generate my form and insert the fields for the data for me. Everything works fine with the exception of the Add button. When I click Add, the numbers on the Navigation controls change, but it will not automatically position itself on the new record that was added. When I try to use the navigation controls to move to the record, it will not move to it. I would appreciate any help that would get me to that elusive new, blank record that I just added.

I have generated other forms with the wizard, and they work just fine. I have posted the code below.

Code:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim dr As DataRow
        Try
            'Clear out the current edits
            Me.BindingContext(objdsWorkOrders, "WorkOrders").EndCurrentEdit()
            Me.BindingContext(objdsWorkOrders, "WorkOrders").AddNew()
        Catch eEndEdit As System.Exception
            System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
        End Try

        Me.objdsWorkOrders_PositionChanged()

    End Sub

Private Sub objdsWorkOrders_PositionChanged()
        Me.lblNavLocation.Text = (((Me.BindingContext(objdsWorkOrders, "WorkOrders").Position + 1).ToString + " of  ") _
                    + Me.BindingContext(objdsWorkOrders, "WorkOrders").Count.ToString)
    End Sub
 
You probably want to take a look at the currencymanager. It also includes positon along with count.

If you can find it, a good beggining book is: "Beginning VB .Net" from WROX. It has a couple of chapters devoted to db programming for both oledb and SQL Server. Another chapter is db programming for the web.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top