
January 7th, 2008, 11:11 AM
|
|
Registered User
|
|
Join Date: Jan 2008
Posts: 1
Time spent in forums: 40 m 9 sec
Reputation Power: 0
|
|
General - Question - Access Violation Error checking for null fields
Hello, I am new with this forum so I hope I'm doing this right.
Anyway, I am using Delphi 2006(a newbie with this also). I have a screen with 5 tabs. I only want to check for null Tedit and Tcombobox fields on tabscreen2. When i click on the update button and if there is a null field, I display an error message for the user to fill the required field in and all is well.
However, if there are no null fields, I get an access violation error when I click the update button. This is my code:
for FldCnt:= 0 to ComponentCount - 1 do
begin
if (Components[FldCnt] is TControl) then
if ((Components[FldCnt] as TControl).Parent.Name = 'TabSheet2') then
if ((Components [FldCnt] is TEdit) OR (Components [FldCnt] is TComboBox)) then
if ((TEdit(Components[FldCnt]).Text = '') OR (Tcombobox(Components[FldCnt]).Text = '')) then
begin
MessageDlg( 'Please enter a value for the required field.', mtInformation, [mbOK], 0 );
exit;
end;
end;
Any help would be greatly appreciated. Thanks!
|