• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

DAO Edit Method in VB 6

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Belcar

Registered
Joined
Feb 21, 2001
Location
Central Illinois
When I try to edit a record in the database (Access 7.0) with this code I end up with :

1) The previous or next record is being deleted

2) I then have 2 records with the same name as the one I am EDITING

3) There are only 2 FIELDS in the data base and I end up with one empty and one has double what it should have.

What is going on here? :(


Private Sub cmdSave_Click()
Dim Title As String
Dim N As String
Dim R As String
Dim T As String

Title = cmbTitles
N = cmbCatagories 'combobox with Table names
Set rs = db.OpenRecordset(N)
On Error GoTo fixit
R = rtfData.TextRTF
T = cmbTitles

If cmbTitles.Enabled Then
rs.LockEdits = True
rs.Edit
rs.Fields("Title") = T
rs.Fields("Recipe") = R
rs.Update
Set rs = Nothing
Else
rs.AddNew
If txtTitle.Text = "" Then
MsgBox "Belinda, you must add a name for this recipe"
txtTitle.SetFocus
Exit Sub
End If
rs.Fields("Title") = txtTitle.Text
rs.Fields("Recipe") = rtfData.TextRTF
rs.Update
rs.Bookmark = rs.LastModified
Set rs = Nothing
End If
 
Back