Microsoft access warning (1 Viewer)

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
Good morning Specialists,

After input my form fields I click a button to create a mail. Works fine.

Before the "email code" starts, the user has the possibility to save the record and continue or not and cancel.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
   
   ' Specify the message to display.
   Beep
   strMsg = "Wil je deze aanvraag bewaren?" & vbLf & "Klik ''Yes'' om te bewaren of ''No'' om af te sluiten." & vbLf & vbLf
   strMsg = strMsg & "Voulez-vous enregistrer cette demande?" & vbLf & "Cliquez sur ''Yes'' pour enregistrer ou sur ''No'' pour fermer." ' Display the message box.
   iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
        
        ' Check the user's response.
        If iResponse = vbNo Then
           ' Undo the change.
           Me.Undo
           ' Cancel the update.
           Cancel = True
        End If
Hoeveel.SetFocus
End Sub
When clicked "Yes" the code continues and the email appears. So far so good.:)

When clicke "No" I have a message :

The setting you entered isn't valid for this property.

I click OK, the form is reseted and I can restart the process.

Why do I get this message?

Thanks

Greetz

Pascal :cool:
 

JHB

Have been here a while
Local time
Today, 21:49
Joined
Jun 17, 2012
Messages
7,732
Try to comment out the "Me:Undo".
 

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
JHB,

Thanks for reply

But I don't know what you mean…:(
 

JHB

Have been here a while
Local time
Today, 21:49
Joined
Jun 17, 2012
Messages
7,732
The line marked with red:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
   
   ' Specify the message to display.
   Beep
   strMsg = "Wil je deze aanvraag bewaren?" & vbLf & "Klik ''Yes'' om te bewaren of ''No'' om af te sluiten." & vbLf & vbLf
   strMsg = strMsg & "Voulez-vous enregistrer cette demande?" & vbLf & "Cliquez sur ''Yes'' pour enregistrer ou sur ''No'' pour fermer." ' Display the message box.
   iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
        
        ' Check the user's response.
        If iResponse = vbNo Then
           ' Undo the change.
           [B][COLOR=Red]'Me.Undo[/COLOR][/B]
           ' Cancel the update.
           Cancel = True
        End If
Hoeveel.SetFocus
End Sub
 

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
JHB,

Thanks.

I already try that. I'm having the same message and my Form doesn't clear. :(
 

JHB

Have been here a while
Local time
Today, 21:49
Joined
Jun 17, 2012
Messages
7,732
Could you post your database with some sample data, zip it!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:49
Joined
May 7, 2009
Messages
19,169
not tested, but you can try adding code
to the form's Error event:
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Debug.Print DataErr
    Response = acDataErrContinue
End Sub
 

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
#JHB, #arnelgp

Thanks for reply.

#arnelgp : I have the same result with your solution.

I mannaged to reduce my DB with the form in question.

Fill in the green fields, click next and click then "NO". The message will apear.

View attachment Example.zip

I hope the example works… :eek:

Thanks a lot

Greetz

Pascal :cool:
 

JHB

Have been here a while
Local time
Today, 21:49
Joined
Jun 17, 2012
Messages
7,732
I do not get the error you mention, (but something else according to the Error$)!

Did you try the database you posted?

Do a "Compact & Repair".


And please next time, if you want people to help you: DON'T Lock anything in the database.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:49
Joined
May 7, 2009
Messages
19,169
check the single change in the code.
 

Attachments

  • Example_2.zip
    124.9 KB · Views: 144

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
#JHB,

I still have the same error, even with the database I posted. Even after Compact & repair...

See photo…


#arnelgp,

Your solution is working…

Can you please tell me what you changed? If I compere your code with the original I send as example, I can not see immediately the difference … :(

Thanks

Greetz

Pascal :cool:
 

Attachments

  • Access message.JPG
    Access message.JPG
    62 KB · Views: 159

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:49
Joined
May 7, 2009
Messages
19,169
on the click event of "Next" button,
you set:

If Me.Dirty Then Me.Dirty=False

Me.Dirty=False, conflicts with BeforeUpdate event.

the solution is check if the form is dirty,
and pass it to BeforeUpdate event:

If Me.Dirty Then Call Form_BeforeUpdate(0)
 

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
#arnelgp,

Thanks for reply.

It's not working yet like it supose to… :(

I'm gonna do my best to explane… :rolleyes:

What happens in the orignal version :

I fill in the different fields in the "Verlofaanvraag" Form. After input I click NEXT.
the "msgBox" apears to save the record or not.
After click Yes, a form "FormOpgelet" opens (with a last warning and a small explanation for the user).
In that form I click OK, the record in the "Verlofaanvraag" form gets saved, the warningform closes and the email starts up.
I send the mail, if not I close the mail without save.
I close the "Verlofaanvraag" form.

When I click No in the "msgbox", The inputs are removed from the form (blank form) and I can restart the process or close the form.

Of course with the message after clicking No : "The setting you entered isn't valid for this property."


What happens with your change of code :

I fill in the different fields in the "Verlofaanvraag" Form. After input I click NEXT.
the "msgBox" apears to save the record or not.
After click Yes, the form "FormOpgelet" opens (with a last warning and a small explanation for the user).
In that form I click OK, the record in the "Verlofaanvraag" form IS NOT saved yet, the warningform closes and the email starts up.
I send the mail, if not I close the mail without save.
When I close the "Verlofaanvraag" form. The "msgBox" (save Yes-No) appears again. If I click Yes, the warning form opens again and when I click Cancel the Warningform closes, The FormVerlofaanvraag" is already closed and the record is saved. (I can see that when I reopen)

When I click No in the "msgbox" (save Yes-No), The WarningForm apears again (and that should not happen, so I click Cancel otherwise the email will start again) The inputs are removed from the form (blank form) and I can restart the process or close the form.

Of course this time without the message : "The setting you entered isn't valid for this property."

So the whole process is doing a little strange Now….

Greetz

Pascal :cool:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:49
Joined
May 7, 2009
Messages
19,169
I see, try again pascale
 

Attachments

  • Example_2.zip
    129.7 KB · Views: 167

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
Good morning arnelgp,

Thanks for reply :)

I figgered out the changes you did… :p

One thing didn't work yet :

When the "msgBox" apears (to save the record or not), I click to No and the "WarningForm" opens again (and that should not happen) so I added the following code in this part (your schanges) :

Code:
    If Me.Dirty Then
        Dim strMsg As String
        Dim iResponse As Integer
        ' Specify the message to display.
        Beep
        strMsg = "Wil je deze aanvraag bewaren?" & vbLf & "Klik ''Yes'' om te bewaren of ''No'' om af te sluiten." & vbLf & vbLf
        strMsg = strMsg & "Voulez-vous enregistrer cette demande?" & vbLf & "Cliquez sur ''Yes'' pour enregistrer ou sur ''No'' pour fermer." ' Display the message box.
        iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
                
        ' Check the user's response.
        If iResponse = vbNo Then
           ' Undo the change.
           Me.Undo
[COLOR=darkred][B]   --> Exit Sub <--
[/B][/COLOR]       ' Cancel the update.
        Else
            On Error Resume Next
            bolErrorHandled = True
            DoCmd.RunCommand acCmdSaveRecord
            bolErrorHandled = False
            On Error GoTo 0
        End If
        Me.Hoeveel.SetFocus
    
    End If
Is this correct? Or is there another way to solve this?

Thanks

Greetz

Pascal :cool:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:49
Joined
May 7, 2009
Messages
19,169
test it again, if it's okey, then it's okey.
right now.. i have many db download as
per request and pm, I am still looking for your db.
 

scallebe

Registered User.
Local time
Today, 21:49
Joined
Mar 23, 2018
Messages
51
#arnelgp,

I can imagine that… :eek:

No problem, I am grateful for what you have done already.

I added the "Exit sub" and it works fine.

I just wanted to know if my solution is the right way.

Please let me know when you have the time...

Thanks again

Greetz

Pascal :cool:
 

Users who are viewing this thread

Top Bottom