Edit data from vb 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dem012
    New Member
    • Dec 2008
    • 7

    Edit data from vb 2005

    Hello i have link a microsoft access database in visual basic 2005.I Try to make a bonus card aplication form so i make the code for add and cancel data for a new customer.Now i want to make a button to edit and update thethe customer that is already added because maybe i need to change it smt like andtress telephone and etc. can you help me with the code pls

    ps :the edit button i want it to open a new form and give me a combobox to find the user and edit it (if is any provlem with a new form i can put it in the ford that is allready exist and edit it there

    Remember that the ms access is linked to the vb and anything change in the form must save it in the ms access database

    thnks for listen me

    Sincerely Andreas
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings, Andreas!

    I believe you'll need something like this:

    [CODE=VB]
    ... you should do a bunch of stuff here
    ... dimension your database as database
    ... dimension your recordeset as recordset
    Set my_record = my_database.Ope nRecordset("sel ect * from MovieData_Table where MovieTitle='" & Text1(1).Text & "'") 'you must first search for the data to be updated
    my_record.Edit 'begin your editting process
    my_record!Movie Title = Text1(1).Text 'first field to be updated
    my_record!Movie Type = Text1(2).Text 'second field to be updated
    my_record!Ratin gScale = Text1(3).Text 'third field to be updated
    my_record!Movie Location = Text1(4).Text 'fouth field to be updated
    my_record!Movie Format = Text1(5).Text 'fifth field to be updated
    my_record.Updat e 'fully update your data, then close
    ...you'll need to close here
    [/CODE]

    Please post what you have working thus far so we know where you are.

    Good luck with the project:-)
    Last edited by Dököll; Dec 6 '08, 05:16 PM. Reason: text...

    Comment

    • dem012
      New Member
      • Dec 2008
      • 7

      #3
      Hello again in the 1 line 2 line and 3rd what are u mean? the edit in is in combo box or just in text box?

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Show us what have you done so far.


        Rey Sean

        Comment

        • dem012
          New Member
          • Dec 2008
          • 7

          #5
          Hello again sorry for late no internet connection.I have use the binding menu and when i load the form the first customer fields appear. I dont want this i want to select from combo box (example Customer.ID 3 ) and the details of this customer to see only.


          download the file from rapidshare i dont know how to insert it here thnks and sorry

          and the code
          ------------------------------------------------------------------------------------------------------------------
          Public Class Form1



          Private Sub CustomersBindin gNavigatorSaveI tem_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles CustomersBindin gNavigatorSaveI tem.Click
          Me.Validate()
          Me.CustomersBin dingSource.EndE dit()
          Me.CustomersTab leAdapter.Updat e(Me.Db1DataSet .Customers)

          End Sub

          'Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
          'TODO: This line of code loads data into the 'Db1DataSet.Cus tomers' table. You can move, or remove it, as needed.
          'Me.CustomersTa bleAdapter.Fill (Me.Db1DataSet. Customers)



          Private Sub Label2_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label2.Click

          End Sub

          Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button2.Click
          CustomerIDTextB ox.Text = ""
          CNameTextBox.Te xt = ""
          CSurnameTextBox .Text = ""
          HomeTelTextBox. Text = ""
          MobileTelTextBo x.Text = ""
          CountryTextBox. Text = ""
          CityTextBox.Tex t = ""
          BonusCardTextBo x.Text = ""
          AndressTextBox1 .Text = ""
          Postal_codeText Box1.Text = ""
          EmailTextBox1.T ext = ""
          FaxNumTextBox1. Text = ""
          NotesTextBox.Te xt = ""
          End Sub

          Private Sub BonusCardTextBo x_TextChanged(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles BonusCardTextBo x.TextChanged

          End Sub

          Private Sub AndressTextBox1 _TextChanged(By Val sender As System.Object, ByVal e As System.EventArg s) Handles AndressTextBox1 .TextChanged

          End Sub


          Private Sub BtnEXIT_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles BtnEXIT.Click

          If MsgBox("Are You Sure You Want to Exit", MsgBoxStyle.Yes No, "Nicolaou Department Store") = MsgBoxResult.Ye s Then
          End
          Else
          MsgBox("Welcome Back", MsgBoxStyle.OkO nly, "Nicolaou Department Store")
          End If
          End Sub

          Private Sub BindingNavigato rAddNewItem_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles BindingNavigato rAddNewItem.Cli ck

          End Sub

          Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click


          If Me.Validate Then
          Me.CustomersBin dingSource.EndE dit()
          Me.CustomersTab leAdapter.Updat e(Me.Db1DataSet .Customers)
          Else
          System.Windows. Forms.MessageBo x.Show(Me, "Validation _errors occurred.", _
          "Save", System.Windows. Forms.MessageBo xButtons.OK, _
          System.Windows. Forms.MessageBo xIcon.Warning)
          End If
          End Sub

          Private Sub Form1_Load(ByVa l sender As System.Object, _
          ByVal e As System.EventArg s) Handles MyBase.Load

          ' TODO: This line of code loads data into the
          ' NorthwndDataSet .Customers table. You can move,
          ' or remove it, as needed.
          Me.CustomersTab leAdapter.Fill( Me.Db1DataSet.C ustomers)
          End Sub
          -------------------------------------------------------------------------------------------------------------------

          Comment

          • dem012
            New Member
            • Dec 2008
            • 7

            #6
            anyone help pls .........

            Comment

            • lotus18
              Contributor
              • Nov 2007
              • 865

              #7
              If you want to insert an image, just click the image icon and put the link of your image, same thing with your codes enclosed them with code tags.


              Rey Sean

              Comment

              • lotus18
                Contributor
                • Nov 2007
                • 865

                #8
                Originally posted by dem012
                I have use the binding menu and when i load the form the first customer fields appear. I dont want this i want to select from combo box (example Customer.ID 3 ) and the details of this customer to see only.
                Try the SelectedIndexCh anged event of your combobox. And also, make your connection as dynamic as possible. You can use WHERE clause in sql statement for filtering your records. Goodluck.

                Code:
                Private Sub Form1_Load(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles MyBase.Load
                
                ' TODO: This line of code loads data into the
                ' NorthwndDataSet.Customers table. You can move,
                ' or remove it, as needed.
                Me.CustomersTableAdapter.Fill(Me.Db1DataSet.Customers)
                End Sub


                Rey Sean
                Last edited by lotus18; Dec 13 '08, 04:10 AM. Reason: for

                Comment

                • dem012
                  New Member
                  • Dec 2008
                  • 7

                  #9
                  i want to have a combobox and the combobox to found the name of the customer Example John.C When i choice this name to load the personal information in the textbox i have in the form ... Remember is linked with microsoft db


                  can u help tell me with code pls?

                  thnks for help

                  Comment

                  • dem012
                    New Member
                    • Dec 2008
                    • 7

                    #10
                    anyone pls ?is need as fast you can

                    Comment

                    • dem012
                      New Member
                      • Dec 2008
                      • 7

                      #11
                      anyone pls help?,......... ..

                      Comment

                      Working...