********************************************************* * Program....: CHECKOBLIGATORY * Version....: * Author.....: Koen Piller * Date.......: 28 October 2019, 05:10:06 * Notice.....: No Copyright © Use at your own risk. * Parameters.: * Called by..: * Purpose....: check for all obligatory fields with value ********************************************************** Lparameter oContainer Local liCtrl As Integer, ; llChecked As Boolean, ; lnAnswer As Number, ; lnCtrlCount As Number, ; loControl As Object, ; loControlParent As Objectm m.llChecked = .F. If Parameters() = 0 m.loControlParent = Thisform Else m.loControlParent = m.oContainer Endif Do Case Case Atc("Pageframe",m.loControlParent.BaseClass)#0 m.lnCtrlCount = m.loControlParent.PageCount Case Atc(m.loControlParent.BaseClass,"Optiongroup,Commandgroup")#0 m.lnCtrlCount = m.loControlParent.ButtonCount Otherwise m.lnCtrlCount = m.loControlParent.ControlCount Endcase lcWrong = '' For m.liCtrl = 1 To m.lnCtrlCount Do Case Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"Pageframe") # 0 SET STEP ON This.checkobligatory(m.loControlParent.Pages[m.liCtrl]) Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"Optionbutton") #0 And This.UserControlMode If Pemstatus(m.loControl,"ValueNotEmpty",5) And m.loControl.ValueNotEmpty = .T. m.loControl = (m.loControlParent.Buttons[m.liCtrl]) m.llChecked = .T. If m.loControl.Value = 0 m.lcWrong = m.lcWrong + Chr(10) + Chr(13) + m.loControl.Name m.loControl.BorderColor = Rgb(255,0,0) m.loControl.BorderStyle = 0 m.loControl.ToolTipText = "You have not made a selection" m.loControl.Refresh() Endif This.lIncorrect = Iif(loControl.Value = 0,.T., This.lIncorrect) Endif Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"Optiongroup,Commandgroup") #0 And This.UserControlMode This.checkobligatory(m.loControlParent.Controls[m.liCtrl]) Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"Container") # 0 Or Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"Page") # 0 This.checkobligatory(m.loControlParent.Controls[m.liCtrl]) Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"TextBox") # 0 m.loControl = (m.loControlParent.Controls[m.liCtrl]) If Pemstatus(m.loControl, "Valuenotempty",5) And m.loControl.ValueNotEmpty = .T. And loControl.Name=='txtDate' m.llChecked = .T. If Isempty(m.loControl.Value) m.lcWrong = m.lcWrong + Chr(10) + Chr(13) + m.loControl.Parent.Comment m.loControl.Parent.Shape.Visible = .T. m.loControl.ToolTipText = 'This field cannot be empty' m.loControl.Refresh() Else m.loControl.Parent.Shape.Visible = .F. m.loControl.ResetToDefault("Bordercolor") m.loControl.ResetToDefault("Tooltiptext") Endif This.lIncorrect = Iif(Isempty(m.loControl.Value), .T.,This.lIncorrect) Else If Pemstatus(m.loControl, "Valuenotempty",5) And m.loControl.ValueNotEmpty = .T. m.llChecked = .T. If Isempty(m.loControl.Value) m.lcWrong = m.lcWrong + Chr(10) + Chr(13) + m.loControl.Name m.loControl.BorderColor = Rgb(255,0,0) m.loControl.ToolTipText = 'Thia field cannot be empty' m.loControl.Refresh() Else m.loControl.ResetToDefault("Bordercolor") m.loControl.ResetToDefault("Tooltiptext") Endif This.lIncorrect = Iif(Isempty(m.loControl.Value), .T.,This.lIncorrect) Endif ENDIF Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"TextBox,EditBox") # 0 m.loControl = (m.loControlParent.Controls[m.liCtrl]) If Pemstatus(m.loControl, "Valuenotempty",5) AND VARTYPE(m.loControl) <> 'L' If m.loControl.ValueNotEmpty = .T. m.llChecked = .T. If Isempty(m.loControl.Value) m.lcWrong = m.lcWrong + Chr(10) + Chr(13) + m.loControl.Name m.loControl.BorderColor = Rgb(255,0,0) m.loControl.ToolTipText = 'Thia Field cannot be empty' m.loControl.Refresh() Else m.loControl.ResetToDefault("Bordercolor") m.loControl.ResetToDefault("Tooltiptext") Endif This.lIncorrect = Iif(Isempty(m.loControl.Value), .T.,This.lIncorrect) Endif Endif Case Atc(m.loControlParent.Controls[m.liCtrl].BaseClass,"ListBox,ComboBox,Spinner") # 0 And This.UserControlMode Endcase m.llIncorrect = This.lIncorrect Endfor If !Empty(m.lcWrong) =Messagebox( m.lcWrong, 0+64+0, "You have some fields without a value", 0 ) && OK = 1 Endif Return llIncorrectThis will warn users to give wrong data.