HI,
Im wondering if anyone can help me, my vb.net is not the best and i am trying to create a program that allows the user to search for staff.
i have created a database containing one table with details such as name, depatment, email address i have then created a form in vb containing the database headings as label along with a text box. i have also created a 'search' button.

i want the user to be able to type in a name in to the name text box and i want any reaults to display and then the user can select the appropriate one and i want the details to display i have connected the form to the databse but i dont know how to code the the search button to do what i want

HI,
Im wondering if anyone can help me, my vb.net is not the best and i am trying to create a program that allows the user to search for staff.
i have created a database containing one table with details such as name, depatment, email address i have then created a form in vb containing the database headings as label along with a text box. i have also created a 'search' button.

i want the user to be able to type in a name in to the name text box and i want any reaults to display and then the user can select the appropriate one and i want the details to display i have connected the form to the databse but i dont know how to code the the search button to do what i want

So if I understand you, you basically want to create a search (master - detail). I am still learning so bear with me on this, I have a piece of code that I have written for a similar project. This code is only for reference, begin that your variables will be different i.e., the way you connect to the database, but none the less it should get you going in the right direction....A few notes here this page is part of a MDI (Multiple Document Interface) so anywhere you see that remember that when coding yours, if you are not using a MDI you are referring to the forms name. Example of this is Me.MDIPARENT yours should look like Me.(whatever your form name is ). This code makes uses of standard text boxes not the pre-made ones form the drag and drop feature and the datagrid. This is how far I have gotton, I am still trying to learn how to create the detail pages from the datagrid. So like I said this is to only get you started.

Pay attention to the narratives that are mark with ' they contain important notes. Hope it helps

Public Class Employees

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Inventory_management_databaseDataSet.Employees' table. You can move, or remove it, as needed.
        Me.EmployeesTableAdapter.Fill(Me.Inventory_management_databaseDataSet.Employees)

    End Sub

    Private Sub firstname1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles firstname1.TextChanged
        'First Name search field fillter
    End Sub

    Private Sub lastname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lastname.TextChanged
        'Last Name search field fillter
    End Sub

    Private Sub Title_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Title.SelectedIndexChanged
        'Title search field fillter
    End Sub

    Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click
        'Runs the the search query and filler against the database and returns result via DataGrid
        Try
            Me.EmployeesTableAdapter.Search(Me.Inventory_management_databaseDataSet.Employees, firstname1.Text, lastname.Text, Title.SelectedItem, EmployeeID.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Edit.Click

        ' Edit the highlighted Employee...
        Dim strEmployeeID As String = ""

        ' Make sure a row is selected...
        If (DataGridView1.SelectedRows.Count = 0) Then
            MessageBox.Show("There are no Employee Records listed to Edit!", "Problem:", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Exit Sub
        End If

        ' Obtain the Employee ID...
        strEmployeeID = DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value


        Dim objedit_employees As New edit_employees
        objedit_employees.MdiParent = Me.MdiParent
        objedit_employees.EmployeeID = EmployeeID
        objedit_employees.Show()
    End Sub
End Class
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.