Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access - VBYesNo to Void Transactions in a Do Loop

Posted on 2012-09-05
2
Medium Priority
?
375 Views
Last Modified: 2012-09-05
Hello
Well, I figured I'd end up with this as a question.  I wanted to insure that if a clerk selected a command button on a form that opens a 2nd Form and then decides "Oops, I didn't want to do that" That the Cancel command button would VOID the transactions that were INSERT INTO the db when selecting the first Form's Command Button.   (Just FYI - when they select a command button on the first form it inserts a Set number of new records into the Db)

When the 2nd form opens it only shows the x number of new records that form1 created.  There the user is supposed to input info for each of the new records created.   If they choose to cancel I have to have those transactions voided due to what is going to happen elsewhere in the program.

The VBYesNo function I set up to cancel doesn't work it keeps going to the Else portion regardless of whether the user selects yes or no.....

Private Sub cmdCancel_Click()
Dim z As Integer
z = 1

If MsgBox("You selected CANCEL.  This will delete the current information.  Are you sure you want to Cancel the input of this information?", vbYesNo, "CANCEL INFORMATION!") = vbOK Then
    Do
        CurrentDb.Execute "Update ShiftReportingLVL set Voided=Yes" _
            & " WHERE RptgSeqID=" & Me.txtMaxSeqID & " And LVLPositionNbr =" & z, dbFailOnError
        z = z + 1
        If z = Val(Me.txtLocationNbrMachines) + 1 Then Exit Do
        
    Loop
    MsgBox "This LVL Reporting information has been voided.  If you still need to record an LVL Reporting you must re-execute the LVL Reporting Main Menu!", vbOKOnly, "NOTICE! LVL REPORTING VOIDED!"
    DoCmd.Close
Else
    MsgBox "You chose to Exit the Cancel function." & vbNewLine & vbNewLine & "Please review the information input.  If your input is complete you must choose either:" & vbNewLine & _
    "i)Save & Close OR ii)Cancel", vbOKOnly, "EXIT THE CANCEL LVL REPORTING PROCEDURE!"
End If

End Sub

Open in new window


Any help on what I have out of order or syntaxed incorrectly?
0
Comment
Question by:wlwebb
2 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 38366970
Try to change vbOK to vbYes, they have different values
0
 

Author Closing Comment

by:wlwebb
ID: 38366989
UUUgggghhhh!!!!!!!!  Thanks!!!!!!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question