ok I have a form where I display data from db.
I find the record based on the date assigned to it and display on form.
I want user to be able to update the date of the record from the form. But if I base my sql on the dates how can I update the date field?
Problem: Can not update a record that doesn't exist!
Code:Case 1 ' updating current record with new data Dim strMsg As String, strNewMsg As String Set rs = New Recordset sql = "SELECT * FROM NEM WHERE MMDD = '" & txtEntry(0).Text & "'" rs.Open sql, cnCon, adOpenDynamic, adLockOptimistic If Not rs.EOF Then ' if record found rs.Update rs.Fields!MMDD = txtEntry(0).Text rs.Fields!MonthDay = txtEntry(1).Text rs.Fields!Title = txtEntry(2).Text rs.Update sql = "" rs.Close Set rs = Nothing Text1(0).SetFocus Else rs.AddNew rs.Fields!MMDD = txtEntry(0).Text rs.Fields!MonthDay = txtEntry(1).Text rs.Fields!Title = txtEntry(2).Text rs.Update sql = "" rs.Close Set rs = Nothing Text1(0).SetFocus End If




Reply With Quote