Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2010
    Posts
    41

    Unanswered: VBA Code error - What error?

    Can someone tell me what is wrong with this code:

    Code:
    Private Sub deleterecord_Click()
    On Error GoTo Err_deleterecord_Click()
    Dim QI As Integer
    QI = MsgBox("Are you sure you want to delete this record?", vbYesNo)
    If QI = vbYes Then
    DoCmd.SetWarnings False
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 <- delete code created via the wizard
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 <- delete code created via the wizard
    DoCmd.SetWarnings True
    End If
    Exit_cmdDeleteRec_Click:
    Exit Sub
    Err_cmdDeleteRec_Click:
    MsgBox Err.Description
    Resume Exit_cmdDeleteRec_Click
    End Sub
    
    Private Sub deleterecord_Click()
    
    End Sub
    I tried to put a custom error message in when i didnt realise access already has on so i dont need it - now i want to delete the code i put in, but i keep getting loads of pop up boxes with the code in for each of my forms...how can i get rid of it?
    Last edited by redsky; 04-21-10 at 08:34.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oh ye gods - you must MUST MUST put DoCmd.SetWarnings True somewhere where it will always be run without exception. In this case, after Exit_cmdDeleteRec_Click:.

    DoCmd.SetWarnings False is a disaster waiting to happen - only ever use it if you have absolutely no alternative - NONE AT ALL.

    Other than that no I have no idea what is wrong - gizza clue: do you not get a message to tell you the error?

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Also, has no one mentioned the code tags? Wrap this round your code: [ code][ /code] (minus spaces). Makes it easier to read.

  4. #4
    Join Date
    Mar 2010
    Posts
    41
    thanks for your reply - sorry i didnt know about the codes...

    how do i just get rid of the whole lot of code from my database? because when i open my database i het a little security warning bar pop up on top and it asks me to click on options to enable vba content - when i do that the vba window open automatically and i get the box pop up with this code which aparently is wrong accroding to access...so i just want to be able to enable vba content and get rid of this code -i dont want it at all

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    What do you mean by get rid of the code? Do you mean VBA code? If so, just delete it.

  6. #6
    Join Date
    Mar 2010
    Posts
    41
    i have tried to delete it but each time i open up access it pops up!

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    So the code you posted in post #1 is now deleted from your database? But when you open the database it reappears?

  8. #8
    Join Date
    Mar 2010
    Posts
    41
    yes it reappears in another form

  9. #9
    Join Date
    Mar 2010
    Posts
    41
    im trying to delete the microsoft access class objects...

Posting Permissions

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