Hi,
I have a quastion about a msgbox that pops up twice instead of just one time.
Here's the code, which is in the beforeupdate event of a form;
On the form there is a button which has the following code;
The only way to close the form is by pressing the button.
When i press the butto, i nicely get the fields which the user failed to fill out.
However when i discard of that messagebox, it pops up again. When i then discard it, it does not pop up anymore, untill i press the butto again, which will trigger the events again.
Can anyone please help me so that the messagebox appears only once ?
Thank you very much !
Pierkes
I have a quastion about a msgbox that pops up twice instead of just one time.
Here's the code, which is in the beforeupdate event of a form;
Code:
Private Sub Form_beforeupdate(Cancel As Integer) Dim ctl As Control For Each ctl In Me.Controls If ctl.Tag = "vereist" Then If LenB(Nz(ctl, vbNullString)) = 0 Then MsgBox ("Vul iets in voor " & ctl.Name & "!"), , "Melding incomplete gegevens" ctl.SetFocus Cancel = True Exit Sub End If End If Next ctl If Me![tr_result] <> "Open" And IsNull(Me![tr_reden]) Then MsgBox ("Vul aub een reden in waarom iets niet door is gegaan!"), , "Melding incomplete gegevens" Cancel = True End If End Sub
Code:
Private Sub cmdSaveandNew_Click() On Error GoTo cmdSaveandNew_Click_Err On Error Resume Next If (Form.Dirty) Then DoCmd.RunCommand acCmdSaveRecord End If If (MacroError.Number <> 0) Then Beep MsgBox MacroError.Description, vbOKOnly, "" Exit Sub End If On Error GoTo cmdSaveandNew_Click_Exit DoCmd.GoToRecord , "", acNewRec DoCmd.GoToControl "Naam relatie" cmdSaveandNew_Click_Exit: Exit Sub cmdSaveandNew_Click_Err: 'MsgBox Error$ Resume cmdSaveandNew_Click_Exit End Sub
When i press the butto, i nicely get the fields which the user failed to fill out.
However when i discard of that messagebox, it pops up again. When i then discard it, it does not pop up anymore, untill i press the butto again, which will trigger the events again.
Can anyone please help me so that the messagebox appears only once ?
Thank you very much !
Pierkes
Comment