I found the problem. It was th function IsNull(), because you cannout use it for checkboxes. Therefore you have to check for False. But there still some optimizations, which would be fine to implement.
1. There are more than one field Form![marr]. basically its a query, which loops through data and puts out one or more fields. My question how could I implement this situation in vba, so that my code is checking every field and not just the first one?
2. There three different situations, but one situation could follow after the other. I say it clearly, the first and the second if statement could be true at the same time. My code is just checking the first and would ignore the second, but how could code of second if statement also doable?
Would be nice if somebody could give me some adivises, thanks mates
Code:
Private Sub Combo471_AfterUpdate()
'Variablendeklarationen
Dim strTitle As String
Dim strPormpt As String
strTitle = "Achtung!"
strPrompt = "Sie haben blablabla angegeben. Jedoch liegt ihr angegebenes blabla (" & Me![subformB].Form![Field1] & ") in der Vergangenheit." _
& vbCrLf & "Bitte prüfen Sie, ob dies so korrekt ist. Andernfalls Bitte ändern Sie das blabla entsprechend."
'Prufen ob Feld blabla leer, bei gleichzeitigen blablabla 3 - 5
If IsNull(Me![subformB].Form![Field1]) And (Me!Combo471 = "3" Or Me!Combo471 = "4" Or Me!Combo471 = "5") Then
'Wenn dem so ist, Aufruf einer Msg.Box, extern
Select Case MsgBox2(Title:="Achtung", _
Prompt:="Sie haben blablabla " & Me.Combo471 & " angegeben aber kein blabla." & vbCrLf & "Bitte geben Sie ein entsprechendes blabla an", _
Buttons:=vbButton2 + vbInformation, _
UserButton1:="Jahr manuell eintragen", _
UserButton2:="Aktuelles Jahr eintragen")
Case vbButton1
MsgBox "Ok, blabla kann manuell eingetragen werden!", vbOKOnly + vbInformation, "blabla wird so belassen"
Case Else
MsgBox "Aktuelles Jahr wird eingetragen!", vbOKOnly + vbInformation, "Aktuelles Jahr"
Me![subformB].Form![Field1] = Year(Date())
End Select
'Falls nicht zutrifft dann pruefen,ob Hersteller ab blablabla 3 als guck gekennzeichnet ist oder nicht ob
ElseIf (Me![subformA].Form![marr]=False) And (Me!Combo471 = "3" Or Me!Combo471 = "4" Or Me!Combo471 = "5") Then
'Aufruf der selben Messagebox, wie bei anderen Routinen
Select Case MsgBox2(Title:="Achtung", _
Prompt:="Sie haben den blablabla" & Me.Combo471 & " angegeben aber denhossa nicht als guck gekennzeichnet" & vbCrLf & "Bitte kennzeichnen Sie den als guck.", _
Buttons:=vbButton2 + vbInformation, _
UserButton1:="hossa als guck kennzeichnen", _
UserButton2:="marr manuell kennzeichnen")
Case vbButton1
MsgBox "hossa wird als guck gekennzeichnet!", vbOKOnly + vbInformation, "hossa guck"
Me![subformA].Form![marr].Value = True
Case Else
MsgBox "Ok,hossa wird manuell als guck gekennzeichnet!", vbOKOnly + vbInformation, "hossa nicht guck"
End Select
'Als dritte Alternative pruefen, bei blablabla 3 als Fall, ob blabla in der Verangenheit
ElseIf Me!Combo471 = "3" And Me![subformB].Form![Field1] < Year(Date()) Then
Select Case MsgBox2(Title:=strTitle, _
Prompt:=strPrompt, _
Buttons:=vbButton3 + vbInformation, _
UserButton1:="blabla so belassen", _
UserButton2:="Aktuelles Jahr eintragen", _
UserButton3:="Derzeitiges blabla löschen und neues manuell eintragen")
Case vbButton1
MsgBox "Ok, blabla wird so belassen", vbOKOnly + vbInformation, "blabla wird so belassen"
Case vbButton2
MsgBox "Aktuelles Jahr wird eingetragen!", vbOKOnly + vbInformation, "Aktuelles Jahr"
Me![subformB].Form![Field1] = Year(Date())
Case Else
MsgBox "blabla wird gelöscht! Neues kann manuell eingetragen werden", vbOKOnly + vbInformation, "Löschen"
Me![subformB].Form![Field1] = ""
End Select
'Trifft keiner der Situation zu, dann Sub verlassen
Else
Exit Sub
End If
End Sub