none
How to open a bound form to a new record/item without filling the datatable?

    Question

  • How to open a bound form to a new record/item without filling the datatable?

    e.g. Open the form for data entry, without returning the existing records in the bound table.

    I am currently using the dataset designer to bind this form. There is a tableadapter fill statement in the form's load event. I tried to bypass the fill on load, I could add a new item in the form, but when I tried to save, nothing happened. 

    Thank you. -ME


    Wednesday, March 29, 2017 9:16 AM

All replies

  • Hello,

    One idea is to create a new SELECT query that on Fill returns zero records e.g.

    In the designer

    My code

    Public Class Form1
        Private Sub CustomersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) _
            Handles CustomersBindingNavigatorSaveItem.Click
            Me.Validate()
            Me.CustomersBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.DataSet1)
    
        End Sub
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) _
            Handles MyBase.Load
    
            'TODO: This line of code loads data into the 'DataSet1.Customers' table. You can move, or remove it, as needed.
            Me.CustomersTableAdapter.FillByNone(Me.DataSet1.Customers)
    
        End Sub
    End Class
    

    On form load


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, March 29, 2017 9:42 AM
    Moderator