locked
Access/Visual Basic RRS feed

  • Question

  • using Access as the front end. I have created a delete record command button using the wizzard but it will not work. What is the code in Visual Basic to run a delete record command button?
    Tuesday, May 8, 2007 3:03 PM

Answers

  • mrsgwen,

     

    Delete rows from a table in the Access database: Add the following code to the btnDelete_Click event handler:

     

    Code Snippet

    Dim i As Integer

    Dim rno As Integer

    rno = InputBox("Enter the Row no to be deleted: Row no starts from 0")

    Try

    'Delete a row from the Student table.

         DataSet11.Tables(0).Rows(rno).Delete()

    'Update the Student table in the testdb database.

         i = OleDbDataAdapter1.Update(DataSet11)

    Catch ex As Exception

        MsgBox(ex.Message)

    End Try

    'Displays number of rows updated.

    MessageBox.Show("no of rows updated=" & i)

     

    This forum supports Visual Basic.NET (7, 7.1, 8, ...) issues only, so, your Visual Basic 6 question is an off-topic here and this isn't the best place to ask it, here is a list of forums, newsgroups, resources and sites, to get an answer about your question :

    Tuesday, May 15, 2007 5:07 AM