For "update" just use the same code as cmdAdd_Click, but without the AddNew line.
(Microsoft MVP from July 2007 to June 2017) . . . . . . . . . . Hitchhiker's Guide to Getting Help at VBForums Database Development FAQs/Tutorials (updated May 2011) (includes fixing common DB related errors, and [VB.Net] ADO.Net Tutorial, and [Classic VB] ADO tutorial /further steps) other useful DB bits: . Connection strings (alternative copy).•. MDAC/Jet/ACE downloads .•. SQL Server downloads . Classic VB FAQs (updated Oct 2010) (includes fixing common VB errors) some of my Classic VB bits: . Tutorial: How to automate Excel from VB6 (or VB5/VBA) .•. SQL 'Select' statement formatter/checker .•. Convert colour number to colour name .•. FlexGrid: fill from recordset .•. FlexGrid: AutoSize columns .•. DB Reserved Words checker .
VB Code: Private Sub cmdAdd_Click() With rs .AddNew 'adding new record .Fields("field2") = Text1.Text 'setting field2 = whatever is typed in text1 .Fields("field3") = Text2.Text 'as above .Fields("field1") = combo1.Text 'as above .Update 'this updates the recordset etc. End With End Sub Hi, for "update" existing data....which code should I delete please..??? Thanks, Jennifer
Private Sub cmdAdd_Click() With rs .AddNew 'adding new record .Fields("field2") = Text1.Text 'setting field2 = whatever is typed in text1 .Fields("field3") = Text2.Text 'as above .Fields("field1") = combo1.Text 'as above .Update 'this updates the recordset etc. End With End Sub
Forum Rules