i would like to have two msg boxes yes/no. The first one for saving the form and the second one for printing. Although the following code is working:
Private Sub CmdPrint_Click()
DoCmd.OpenReport Frm, acViewNormal
End Sub
It’s not working within a yes/no MsgBox, it seems that the information is not parsed.
I’m not a programmer, but I like to learn it, probally it’s bad on all sides 😀
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Je staat op het punt de ingevoerde gegevens op te slaan." & vbCrLf & vbCrLf & "Weet je zeker dat je dit formulier wilt opslaan?", vbYesNo, "Gegevens opslaan") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
If IsNull(Me.WrkOrdr) = True Then
Me.WrkOrdr = Val(Nz(DMax("[WrkOrdrNr]", "WrkPlts"), "0")) + 1
''# or Me.txt2BookNumber = CLng(Nz(DMax("[BookNumber]", "Participant"), "0")) + 1
End If
If MsgBox("Je staat op het punt dit formulier uit te printen." & vbCrLf & vbCrLf & "Weet je zeker dat je dit formulier wilt uitprinten?", vbYesNo, "Formulier printen") = vbYes Then
DoCmd.OpenReport Frm, acViewNormal
Else
Exit Sub
End If
End Sub
Have you stepped through the code – set a breakpoint by pressing F9 on a line of code, press F8 to run each line ? When you do, does frm have a value? You can check by hovering over it, or by typing ?frm in the immediate window (ctrl+G to toggle immediate window). It should return a string, because report name must be a string. I would suspect that you mean either frm.Name or Me.name, if you had not already said that your original test worked.
BTW for this :
Why not use this:
Also, I would not rely too much on:
And:
The default for Access is to save and there are a couple of things that will stop undo from working in the way you expect.