Adding a new record in a VB 4.0 database

Adding a new record in a VB 4.0 database

When I use my add record button on my form I get blank fields, like I should. However, after I add the new info and move to a different record I find that my new record has overwritten an existing record. I am trying to use the AddNew and Update methods without success. Any advice?Here is the code in the click event of my add button. The info must change on 3 forms.

 Equip.SetFocus      Data1.Recordset.AddNew      Thermal.Data1.Recordset.AddNew      Contam.Data1.Recordset.AddNew      Data1.Recordset.Update      Thermal.Data1.Recordset.Update      Contam.Data1.Recordset.Update

First of all, you have to call the AddNew function before you add your datathrough the bound controls on your form. Most of the forms I saw in theexamples provided by Microsoft had an Add and Update button. To add arecord, you press the Add button, and to save it, you press the Updatebutton. The Add button had the AddNew code in it, and the Update buttonhad the Update code in it. Once you have made that change, you may also have to change the way you arereferencing the Data controls on the other forms. For instance,Therma1.Data1.Recordset.Update may need to becomeTherma1!Data1.Recordset.Update. Try it the way you have it first and if itdoesn’t give you an error, it’s probably ok.

See also  Small Business Strategies with Venmo

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist