Results 1 to 5 of 5

Thread: RS Problems!Can u Fix?

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    RS Problems!Can u Fix?

    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
    Last edited by jesus4u; Jun 6th, 2001 at 01:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width