Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    292

    Unanswered: saving unbound fields

    I have a form which pulls records in from a table.. after the record is pulled in the user has the option of delete or updating the record..

    I tired using the button wizard and tried using the save function, but that doesnt work. I figure its because i have unbound fields..

    my question is how do i get it to update the existing record?

    thanks

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Make sure you pull off the unique identifier, use this to create an editable recordset, then do the update through the recordset.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Jul 2003
    Posts
    292
    Mike thanks for responding.. but could you explain more detail please. I new so thanks for being patient. I wanted to ask you can't I just update the code I have for deleting

    Code:
    Private Sub Command14_Click()
    On Error GoTo Err_bSave_Click
    
    
    Select Case MsgBox("Are you sure you want to DELETE this record?" & vbCrLf & vbLf & "  Yes:         Deletes Record" & vbCrLf & "  No:          Does NOT Delete Record" & vbCrLf & "  Cancel:    Reset (Undo) Changes" & vbCrLf, vbYesNoCancel + vbQuestion, "Delete Current Record?")
            Case vbYes: 'Deletes the changes
                DoCmd.RunSQL "Delete * FROM [tblQR] WHERE [ControlNo] = '" & Me![ControlNo] & "' ;"
                MsgBox "Employee has been Deleted!"
            
            Case vbNo: 'Do not delete or undo
                'Do nothing
    
            Case vbCancel: 'Undo the changes
                DoCmd.RunCommand acCmdUndo
                Me.tbProperSave.Value = "No"
    
            Case Else: 'Default case to trap any errors
                'Do nothing
    
        End Select
    
    Exit_bSave_Click:
        Exit Sub
    
    Err_bSave_Click:
        If Err = 2046 Then 'The command or action Undo is not available now
            Exit Sub
        Else
            MsgBox Err.Number, Err.Description
            Resume Exit_bSave_Click
        End If
    
    End Sub

    I tired changing
    Code:
     DoCmd.RunSQL "Delete * FROM [tblQR] WHERE [ControlNo] = '" & Me![ControlNo] & "' ;"
                MsgBox "Employee has been Deleted!"
    to

    Code:
     DoCmd.RunSQL "Update * FROM [tblQR] WHERE [ControlNo] = '" & Me![ControlNo] & "' ;"
                MsgBox "Employee has been Deleted!"
    but that did not work.. what to do??! please anyone feel free to help

    thanks

  4. #4
    Join Date
    Jul 2003
    Posts
    292
    I got it thanks !

Posting Permissions

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