#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    13
    Rep Power
    0

    Question Maximum Int Field Validation from Rx Lib Field


    Hi,

    Really need help to debug my prob...
    I'm using Borland Delphi 6...and facing problem to do field validation to check the maximum limit check on the field.
    e.g : Age value must be less than 100. I've tried to use StrToInt function, but it generates this error :
    [Error] frmProductsUnit.pas(394): Incompatible types: 'String' and 'TRxDBCalcEdit'


    Below is my code :

    if StrToInt(RxDBCalcEdit2) > 100 then
    begin
    MsgDlg('Bla Bla',mtError,[mbOK]);
    RxDBCalcEdit2.SetFocus;
    Exit;
    end;

    Do you know what's wrong?
    Thanks in advance buddy...
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,595
    Rep Power
    4207
    Yes, change this:
    if StrToInt(RxDBCalcEdit2) > 100 then
    to this:
    if StrToInt(RxDBCalcEdit2.Text) > 100 then
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    13
    Rep Power
    0
    Thanks Scorpion..

    But how to do things like email validation in Delphi 6?
    and also to check the Telephone No, e.g: I want the Telephone No to have "0+12+3456789" format. Is it possible?
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,595
    Rep Power
    4207
    >> But how to do things like email validation in Delphi 6
    How close do you want to do email validation? Do you want to merely check if the e-mail address appears correct (e.g. Scorpions4Ever@someemailaddress.com) or do you want to actually send an e-mail to verify that it is a valid working address. For the first case, you can easily write a validation routine to check that there's an @ sign, domain name and so on.

    >> I want the Telephone No to have "0+12+3456789" format.
    I don't really use the Rx components, but the standard TMaskEdit component allows you to specify a mask for the edit box and you can specify one that does exactly what you want.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    13
    Rep Power
    0
    Thanks Scorpion...

    For the Telephone No. format, actually I'm doing a project to fix the bugs of the existing system. The previous programmer uses TRxDBComboEdit for TelNo. field, and inside there already have the default Phone EditMask which is (###)###-####. I want to change it to 0+12+3456789 format, but it seems the TRxDBComboEdit component does not have EditMask properties as in TMaskEdit component, and even from the source code, I can't see anything about EditMask. I dont know where to change it to 0+12+3456789 format.

    One more thing, I also have a Product Code field, using TDBEdit component, and need to do field validation for the maximum length is 6 and should be 3 characters followed by 3 numeric. In addition, its 1st character depend on the Provider field. For example, if Provider = 'Software', then the Product Code 1st character is S, and if Provider = 'Hardware', then the Product Code 1st character is H. Is this possible to do such field validation?

    Thanks in advance buddy....
  10. #6
  11. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,595
    Rep Power
    4207
    You can do validation in quite a few places.
    1. On the TDBField.OnChange event
    2. On the TDBField.OnExit event. Check the TDBField.Modified property to see if the data in it has changed or not.
    3. On the dataset's BeforePost event.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    13
    Rep Power
    0
    The Telephone field is actually hidden at the TQuery object, I can right click on the TQuery object and go to Field Editor. Then can put the necessary Edit Mask there...hehe...

    But one problem that i'm facing though, I've successfully put in the necessary Edit Mask for the Telephone field. But can we customize on the Message Dialog appear. Currently the Message Dialog that appear when user key-in an invalid value for the Telephone field is "Invalid input value. Use escape key to abandon changes.". Can we customize this?

    I've tried to do it at the Telephone field OnExit event, and I put If Length(TelNo.Text)<9 then raise Exception.Create(telNoError); But I think the Length function cannot be used here, coz the EditMask already consider the field is not empty and length >0.

    So, is it possible to customize the Message Dialog?


    Another thing is, how to differentiate between the value and text at the combo box. Here is my code:

    SQL.text = 'select civil_status, civil_status_desc from civil_status';
    Open;
    civil_status.Items.Clear;
    civil_status.Items.Add(' ');
    While Not EOF Do
    begin
    civil_status.Items.Add(Fields[0].AsString);
    Next;
    end;
    Close;

    How can I make the combobox value to Fields[0], and the combobox text to Fields[1]?

    Thanks in advance...
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Behind you
    Posts
    19
    Rep Power
    0

    ehm


    ehm..i don't understand..
    the SQL rule for select is
    'SELECT field FROM table WHERE conditions ORDER BY field'.
    Another Hint i would say to you is to use the property FieldByName of the Table (or Query).

    Sincerly I don't understand your last question.
    Combobox don't have the value property!

    Or..Do you want to fill the items of the combobox with the fields of the table? ..

    try to explain it well 'cause I'm italian and I'm silly..:P

IMN logo majestic logo threadwatch logo seochat tools logo