Code running report despite default set to not (2 Viewers)

Are these other projects on the same machine?
Yes
You COULD have a situation where an app does something that no other app does.
That's the case with this app. I did the Application.SaveAsText that Tom suggested and did not see any corruption. I also examined that forms code with a hex editor, but that was useless. So instead of beating this dead horse I did not use the vbDefaultButton2 constant, inverted my logic to the default Yes button, "DON'T print customer receipt?", and that works ugh.

Maybe some gremlin changed the vbNo constant to vbYes 👹

Code:
Private Sub cmdPrintReceipt_Click()
Dim response as String
response = MsgBox("DON'T Print Customer Receipt?", vbYesNo)
If response = vbYes Then Exit Sub
DoCmd.OpenReport "rptPrintCustomerReceipt", , , "[ContractNo] = " & Me.ContractNo
End Sub
 
Last edited:
Yes

That's the case with this app. I did the Application.SaveAsText that Tom suggested and did not see any corruption. I also examined that forms code with a hex editor, but that was useless. So instead of beating this dead horse I did not use the vbDefaultButton2 constant, inverted my logic to the default Yes button, "DON'T print customer receipt?", and that works ugh.

Maybe some gremlin changed the vbNo constant to vbYes 👹

Code:
Private Sub cmdPrintReceipt_Click()
Dim response as String
response = MsgBox("DON'T Print Customer Receipt?", vbYesNo)
If response = vbYes Then Exit Sub
DoCmd.OpenReport "rptPrintCustomerReceipt", , , "[ContractNo] = " & Me.ContractNo
End Sub
This worked for me:
Code:
Dim Response As Variant
Response = MsgBox("Run Report", vbYesNo + vbQuestion + vbDefaultButton2)
If Response = 7 Then Exit Sub
MsgBox "Run Report"
Exit Sub
The default is No so if you hit Enter, No (7) is selected and then Exit Sub, otherwise the message box shows "Run Report" and continues to Exit Sub.
I don't use single line If-Then statements but since you did, I did too. Can you run this routine OK?
 

Users who are viewing this thread

  • Back
    Top Bottom