Hi John.
Thanks for your answer!
Here's what I 've got so far:
_______________________
Private Sub Kennzeichen_BeforeUpdate(Cancel As Integer)
CheckKennzeichenOK
Cancel = Not (Me.GetCarRegOK)
If Me.GetCarRegOK = False Then
MsgBox "Please input a valid car registration number!!", _
vbExclamation, "Input or change car registration number"
SetCarRegOK (False)
End If
End Suib
_______________________
Public Static Sub CheckCarRegOK()
Dim result
If Not IsNull(Me.CarReg) Then
' take out spaces and other unnice stuff
outStr = ErrorChecking.fStringValid(Form__frmCar.CarReg.Value)
' if regnumber already in db
result = ErrorChecking.CheckDoubleRegNr(outStr)
If result > 0 Then
' is it in for current customer
result = ErrorChecking.CheckCarForOwner(outStr,
Form__frmCar.CustID)
If result = 1 Then
' yes it is in for current customer
Me.SetCarRegOK (True)
Me.cmdDeleteCar.Enabled = True
SetCheckedKennzeichen (outStr)
Else
result = ErrorChecking.GetNameOfCarOwner(outStr)
' get real owner for carRegNumber
Me.SetCarRegOK (False)
Me.cmdDeleteCar.Enabled = False
MsgBox "Car registration number already exists for customer"
_
& UCase(result) & " !! ", vbCritical, _
"Car registration number not valid"
End If
Else
Me.SetCarRegOK (True)
Me.cmdDeleteCar.Enabled = True
SetCheckedKennzeichen (outStr)
End If
Else
Me.SetCarRegOK (False)
Me.cmdDeleteCar.Enabled = False
End If
' have to do that visible stuff as otherwiese eventhough the caregnum
entered in
' Form__frmCar.CarReg the details of that car ( work - in subform frmWork
and workdetails assubform of frmWork )
' ar displayed and set the db in kind of shock!!
If Me.GetNewEntryClicked = True Then
Form__frmWork.Visible = True
Me.SetNewEntryClicked (False)
End If
If Me.GetDelCarClicked = True Then
Form__frmWork.Visible = True
Me.SetDelCarClicked (False)
End If
End Sub
_______________________
Public Static Function GetCarRegOK() As Boolean
GetCarRegOK = carRegOK
End Function
_______________________
Public Sub SetCarRegOK(val As Boolean)
carRegOK = val
If Me.GetNewEntryClicked = True Then
Form__frmWork.Visible = True
ElseIf Me.GetDelCarClicked = True Then
Form__frmWork.Visible = True
Else
Form__frmWork.Visible = val
End If
End Sub
________________________
It's probably a bit .... :-| .. ?
Gina