Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

sur champ vide runtime erreur

3 réponses
Avatar
jfd
Re bonjour
Autre question, sur un champ ce code pour interdire le champs vide, ok sur
Access, mais après instal runtime si je supprime mon ingrédient il me sort
une runtime erreur et ferme tout ? Que faire pour éviter cela ? Que rajouter
pour éventuellement fermer juste le formulaire sans sauver ??

Private Sub Basic_ingredients_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "La saisie est obligatoire! //Enter a value in this field!" &
vbLf & vbLf
strMsg = strMsg & "Renseignez l'ingrédient ou appuyez sur la touche
<ESC> du clavier pour annuler les modifications en cours."
strMsg = strMsg & "Enter a value in the field <Basic ingredients> or
press on the key <ESC> keyboard to cancel the modifications in progress."

If Me.Dirty Then
If IsNull(Me.[Basic_ingredients]) Then
MsgBox strMsg, vbCritical, "Saisie obligatoire //Enter a value
in this field"
End
End If
End If
End Sub


Merci par avance
jfd

3 réponses

Avatar
Thierry (ze Titi)
Hello jfd !

As-tu essayé les procédures de gestion d'erreurs ? Regarde du côté de
On Error
dans l'aide en ligne.
Dans ton cas, au début de la sub:
On Error Goto ErrorHandler

et à la fin, après ton dernier End If

Exit Sub
ErrorHandler:
MsgBox Err.Number & vbCrLf & Err.Description
Exit Sub


En ce jour mémorable du dimanche 16/09/2007, tu as émis l'idée
suivante:
Re bonjour
Autre question, sur un champ ce code pour interdire le champs vide, ok sur
Access, mais après instal runtime si je supprime mon ingrédient il me sort
une runtime erreur et ferme tout ? Que faire pour éviter cela ? Que rajouter
pour éventuellement fermer juste le formulaire sans sauver ??

Private Sub Basic_ingredients_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "La saisie est obligatoire! //Enter a value in this field!" &
vbLf & vbLf
strMsg = strMsg & "Renseignez l'ingrédient ou appuyez sur la touche
<ESC> du clavier pour annuler les modifications en cours."
strMsg = strMsg & "Enter a value in the field <Basic ingredients> or
press on the key <ESC> keyboard to cancel the modifications in progress."

If Me.Dirty Then
If IsNull(Me.[Basic_ingredients]) Then
MsgBox strMsg, vbCritical, "Saisie obligatoire //Enter a value
in this field"
End
End If
End If
End Sub


Merci par avance
jfd


--
Cordialement,
Thierry

Tout pour réussir avec Access :
http://www.mpfa.info

Avatar
Gelos64
Essayes de remplacer
End
par
Cancel = True


Private Sub Basic_ingredients_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
If IsNull(Me.[Basic_ingredients]) Then
MsgBox strMsg, vbCritical, "Saisie obligatoire //Enter a value
in this field"
End
End If
End If
End Sub


Avatar
jfd
Bonsoir et merci à vous deux
J'essaye cela demain.


Essayes de remplacer
End
par
Cancel = True


Private Sub Basic_ingredients_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
If IsNull(Me.[Basic_ingredients]) Then
MsgBox strMsg, vbCritical, "Saisie obligatoire //Enter a value
in this field"
End
End If
End If
End Sub