Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2007, 08:37 PM
Registered User
 
Join Date: Jul 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trying to save is deleting and replacing records !

 Hi,

I am trying to save records from a dataform to database table, but the problem I am having is each time I try to save the the 1st record on the database table is deleted and replaced with a new record! But I do want to keep every record. My code is as follows:


Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click

    If CheckBox1.Checked Then
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            DateTimePicker.Refresh()
            TextBox1.Focus()
          Else

          TextBox1.Focus()
        End If
    End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.PCT_BindingSource.EndEdit()
        Me.PCT_TableAdapter.Update(Me.HATDataSet.PCT)
        MsgBox("Record has been updated!", MsgBoxStyle.OkOnly)
           CheckBox1.Checked = False
End Sub


What I am doing wrong? How can I correct it? Thanks.
 
Old August 16th, 2007, 02:12 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Well, I don't know. But I have some non-topic suggestions:

Name your buttons (and all controls) with meaningful names.
Avoid exclamation marks in messages as if they were the very plague itself.

I'm wondering if maybe the .EndEdit is playing a role... I am not familiar with the controls, but it seems—just from the method names—that the saving should be done before the editing is abandoned. (Sheer guess)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Duplicate Records BrianWren Pro VB Databases 1 February 22nd, 2008 01:30 PM
Deleting all the records in a table suthaharmca Beginning VB 6 4 January 2nd, 2008 06:14 PM
Deleting duplicate records ninel SQL Server 2000 3 June 14th, 2006 02:12 PM
deleting or replacing a single element hasdy XSLT 3 March 14th, 2006 12:28 PM
Deleting several records on ASP using checkboxes luisbueno Oracle ASP 1 April 25th, 2005 08:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.