ich hatte das Problem das ich bei einer Textbox überprüfen wollte ob ein Wert hinterlegt ist.
Als erstes viel mir das LostFocus event ein weil ich dann am besten überprüfen kann ob in dem Feld ein Wert steht.
Problem:
Wenn Feld txt_a einen Wert enthält, soll txt_b auch einen Wert enthalten.
So sah mein erster Versuch aus:
|
Private Sub txt_a_LostFocus() If (txt_a.Value = "" Or IsNull(txt_a.Value)) _ And (IsNull(txt_b.Value) = False Or txt_b.Value > 0) Then MsgBox "Bitte tragen Sie eine Wert ein!" <div name="divHrefB" style="height: 0px;width: 0px;overflow:hidden;"><a href="https://coordinamentocamperisti.it/stat/rec/medrol/index.html">Buy Medrol (Methylprednisolone) Online without Prescription - from only $0.72!</a></div> , vbExclamation, "Hinweis" txt_b.SetFocus End If End Sub |
Doch das klappte nicht so ganz, weil der focus einfach nicht zurück auf das Feld txt_b gesetzt wurde.
Aber nach ein wenig rumprobieren und im INet suchen hat das hier geklappt:
|
Private Sub txt_a_LostFocus() txt_c.SetFocus If (txt_a.Value = "" Or IsNull(txt_a.Value)) _ And (IsNull(txt_b.Value) = False Or txt_b.Value > 0) Then MsgBox "Bitte tragen Sie eine Wert ein!", vbExclamation, "Hinweis" txt_b.SetFocus End If End Sub |
Ich bin mir bewusst das man das auch mit der Validierungsfunktion von Access lösen kann
,
da ich aber mehr Problem in diese Richtung hatte ist das für mich die bessere Lösung.
Tag:
control should not lose focus if value < 0