none
Need Help for saving project output in access database.Help please

    General discussion

  • Hello Microsoft team. Im nico, a student from Philippines. i want to learn about visual studio (VB form)

    I made a VB form in visual studio connected to Access database. my project is to have inventory and expenses output form for my Mother business. So it easy for her to input records (my purpose)

    The project is well connected to an access database. because its only use for personal basic usage,small business

    Everytime I run the VB form i made and input data at first it saves the data I input it...but when I re-run the VB form I made, the last data I made is "GONE" and "overwrited" the one I input...

    please help me with this...this is my first project. I only watch tutorials about this.

    I only need is all data input in the VB form will stay in access database as long as it is not manually deleted

    I don't know how to make it.please....thank you in advance...

    as reference this is the codes i made...please help me

    (nicolabajo@gmail.com)

    Public Class MOTORPOOL
        Private Sub MOTORPOOL_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'Motorpool_expensesDataSet.motorpool_expenses' table. You can move, or remove it, as needed.
            Me.Motorpool_expensesTableAdapter.Fill(Me.Motorpool_expensesDataSet.motorpool_expenses)
    
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            NATIONAL.Show()
            Me.Close()
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            EXPENSES_LIST.Show()
            Me.Close()
    
    
        End Sub
    
        Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            Me.Motorpool_expensesBindingSource.AddNew()
            MessageBox.Show("After Filling up the details,Please Click the SAVE BUTTON! Thank You!")
            DATEPICK1.Enabled = True
            TYPEOFCAR.Enabled = True
            MOTOR1.Enabled = True
            MOTOR2.Enabled = True
            MOTOR3.Enabled = True
            MOTOR4.Enabled = True
            MOTOR5.Enabled = True
            MOTOR6.Enabled = True
            MOTOR7.Enabled = True
    
    
        End Sub
    
        Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
            Me.Validate()
            Me.Motorpool_expensesBindingSource.EndEdit()
            Me.Motorpool_expensesTableAdapter.Update(Me.Motorpool_expensesDataSet)
            TableAdapterManager.UpdateAll(Me.Motorpool_expensesDataSet)
            DATEPICK1.Enabled = True
            TYPEOFCAR.Enabled = True
            MOTOR1.Enabled = True
            MOTOR2.Enabled = True
            MOTOR3.Enabled = True
            MOTOR4.Enabled = True
            MOTOR5.Enabled = True
            MOTOR6.Enabled = True
            MOTOR7.Enabled = True
            MessageBox.Show("Success! Record Saved!")
        End Sub
    
        Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
            If MsgBox("Delete Record? Are You Sure?", MsgBoxStyle.YesNoCancel, "Title") = MsgBoxResult.Yes Then
                ' execute command
                Me.Motorpool_expensesBindingSource.RemoveCurrent()
                MessageBox.Show("Record Deleted")
            ElseIf MsgBoxResult.No Then
                'do nothing
    
            End If
    
    
        End Sub
    
        Private Sub MOTOR3_TextChanged(sender As Object, e As EventArgs) Handles MOTOR3.TextChanged
    
    
        End Sub
    
        Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
            Motorpool_expensesBindingSource.MovePrevious()
    
        End Sub
    
        Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
            Motorpool_expensesBindingSource.MoveNext()
    
        End Sub
    End Class

    Wednesday, April 20, 2016 12:01 PM

All replies

  • Hi Nico,

    you are correct: The data should be inside the access database till it is deleted from there.

    But when your database sits next to your executable and is part of your solution, then it might happen that:
    - on build everything will be compiled and the access database that is inside your project is copied so that you have everything required in your build directory.

    - Then you start the application, write data to the access database in your build directory.

    - On the next build, the first step is done again and the access database containing your data is overwritten with the empty database.

    You should check if that is the explanation.

    Another point could be, that the data is not written to the access database for some reason. You should make sure that the data is really written to the table.

    With kind regards,

    Konrad

    Thursday, April 21, 2016 2:21 PM
    Moderator