Results 1 to 6 of 6
  1. #1
    viper is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    26

    Verification Before Delete

    Another question on my Visitor database, woohoo…

    In my Entry form you can issue three different kinds of badges, once you select a badge from the drop down you also set the status of it, for example "Issued" or "Returned". There could be some situations where they will need to delete an entry that was entered in error so I wanted a "Delete" button that would first check the status of the three status fields and if any of the three badges status are set to "issued" I want it to cancel the operation.

    Below is the code I’m working with and it works as long as all three fields have a status of "Returned". But on a record where only one of the badges status shows "Returned" it does not delete the record. I am sure that it has something to do with my IF/OR statement but I’m unsure if what I entered is correct or not, since this is the first time I’ve had to use a function like this. Any help would be greatly appreciated.

    Code:
    Private Sub DeleteEntry_Click()
    On Error GoTo Err_DeleteEntry_Click
     
        Dim stDocName
        Dim stDocName2
        Dim stDocName3
     
        Set stDocName = [VEStatus]
        Set stDocName = [ProStatus]
        Set stDocName = [ORJ2Status]
     
            If MsgBox("You are about to delete an Entry, plase make sure that all 'Issued' badges are 
            marked 'Returned' before continuing. Click 'OK' to confirm deletion or click 'Cancel' to 
            abort.", vbOKCancel + vbCritical, "WARNNING!!!") = vbOK Then
     
                If stDocName = "Returned" Or stDocName2 = "Returned" Or stDocName3 = "Returned" Then
     
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
     
                End If
            End If
    Exit_DeleteEntry_Click:
        Exit Sub
    Err_DeleteEntry_Click:
        MsgBox Err.Description
        Resume Exit_DeleteEntry_Click
     
    End Sub


  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    Dim stDocName2
    Dim stDocName3

    dimmed but not assigned a doc ...i.e.typo I think.

    fyi domenu method you use will not work in 07 and beyond I don't think as they move to ribbons and there is no menu; consider docmd method equivalent.

    Hope this helps.

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    What if you split those statements out into three IF statements?

    Code:
                If stDocName = "Returned" Then
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
                End If
                If stDocName2 = "Returned" Then
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
                End If
                If stDocName3 = "Returned" Then
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
                    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
                End If
    I have never had luck using the "Or" operator in an If statement. I'm sure it is just that I am not using it correctly, but this should work instead.

  4. #4
    viper is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    26
    jgelpi16 - I tried what you suggested and it works now thank you, I thought about seperating out the IF statements but didn't know if that would work either. Thanks

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    In your initial post you have...


    Code:
        Dim stDocName
        Dim stDocName2
        Dim stDocName3
     
        Set stDocName = [VEStatus]
        Set stDocName = [ProStatus]
        Set stDocName = [ORJ2Status]
    You are not giving stDocName1 and stDocName2 values Unless this is just a typo.

  6. #6
    viper is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    26
    Quote Originally Posted by jgelpi16 View Post
    In your initial post you have...


    Code:
        Dim stDocName
        Dim stDocName2
        Dim stDocName3
     
       Set stDocName = [VEStatus]
       Set stDocName = [ProStatus]
       Set stDocName = [ORJ2Status]
    You are not giving stDocName1 and stDocName2 values Unless this is just a typo.

    Yup your right, I cought it at the last second. It was a typo, but didn't realize that there was one without an error.

    And FYI the IF/OR statment I had originaly worked as well. So both ways work. Thanks again for your insight.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. delete records
    By fiamma68 in forum Queries
    Replies: 0
    Last Post: 11-15-2010, 06:54 PM
  2. TableDefs.Delete
    By DaveE in forum Programming
    Replies: 3
    Last Post: 10-31-2010, 07:19 PM
  3. Cmd Button/ Text box verification
    By kaylachris in forum Forms
    Replies: 2
    Last Post: 05-19-2010, 11:06 PM
  4. DELETE query
    By dollygg in forum Queries
    Replies: 1
    Last Post: 04-27-2010, 04:12 PM
  5. verification qry!
    By tom4038 in forum Queries
    Replies: 1
    Last Post: 09-24-2009, 02:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums