Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2005
    Posts
    87

    Unanswered: Problems with delete command...

    I can't figure out whats the problem...sometimes when i press delete button (vba code is written for it) it deletes my record, other times (on other PC's) it won't...altough setups is the same (at least i think so).

    I use split db, and i have form with subform in it.I want to delete whole record (with subform) when i press my delete button.

    here is the vba code i use for that button:

    Dim Msg, Style, Title, Response
    Msg = "Are you sure ?"
    Style = vbYesNo + vbDefaultButton2
    Title = "Delete"
    Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then
    Me.Client.SetFocus

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    Else
    Me.Client.SetFocus

    End If



    Any other options for makeing delete button...? i tried macro, but it also won't work everytime...strange.

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    In later versions of Access, DoMenuItem has fallen out of favor. Try
    Code:
    DoCmd.RunCommand acCmdDeleteRecord
    instead. If that doesn't work either, look in the various References you have set on the various machines (Tools-->References with your VBA editor open) and make them all the same. Sounds like you might have different settings in the different installations of Access.

    Sam

  3. #3
    Join Date
    Oct 2005
    Posts
    87
    Ok thanks, i'll give it a try.


    Strange thing is that i could delete one record on one PC, but couldn't delete another record on the same PC at the same time.Then i reopend DB, and could delete that record too....

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Yes, that sometimes happens when you delete a record from a form's recordset. What I've done to solve that is, immediately after deleting a record, I go to the first record of the recordset (DoCmd.GoToRecord ,,acFirst) to get Access to acknowledge the recordset again. Then you can proceed normally.

    Sam

  5. #5
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    In a form, using Me.Refresh does the same thing, while staying on the same record.

    tc

  6. #6
    Join Date
    Oct 2005
    Posts
    87
    OK i think i solved it with me.refresh before and after delete command...


    Thanks
    Last edited by YZF; 05-29-06 at 06:09.

Posting Permissions

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