Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:00:07+00:00 2026-06-01T20:00:07+00:00

i downloaded a DBDateTimePicker which i am using to edit dates in a table,

  • 0

i downloaded a DBDateTimePicker which i am using to edit dates in a table, a start date and completion date. When appending to a table in normal edit boxes i use the following code before the append and post in order to prevent a completion date being set before a start date.

if  (DTPAddStartDate.Date) > (DTPAddCompletionDate.Date) then
begin

      raise Exception.Create ('The Completion date of a Job can not be before a Start Date');
      abort;
end;

The problem is that i want to be able to achieve the same thing when editing dates via the DBDateTimePickers, if i have similar code on the BeforePost event or something then i will get premature error messages as the user may not have had a chance to edit the other related DBDateTimePicker. I have no idea how i could relate the two fields so that i can validate them together somehow or come up with another solution to the problem, any suggestions?
(Im using an adotable connected to access and the component was downloaded from the following link, http://apollosoft.net/jms/).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:00:09+00:00Added an answer on June 1, 2026 at 8:00 pm

    I guess you are using the TDBDateTimePicker from this page but hard to say, it’s missing in your question at this time.

    However you may use the field’s OnValidate event which is being fired whenever the value is changed, but it’s the stage when the data are going to be written do the database, so it’s IMHO the unnecessary wasting of time.

    You can validate the values before they tries to update the record, what is in the case of (almost ?)
    every DB aware control when you try to exit the control, so you may pretty easily add some validation event, something like OnCanUpdate to your date time picker.

    Because of missing link to the source where did you get your component I’ll assume you are using this TDBDateTimePicker. If you add to the DBDateTimePicker.pas file the following lines and rebuild your package where is installed, the new OnCanUpdate event will appear in the component’s Object Inspector. This event if you use it has one important parameter Allowed, if you set it to True you will allow the component to update the record, if you set it to False (what is default) no data will be updated in your dataset. So it’s the place where you can do the validation and decide you want to update record or not.

    type
      TDBDateTimePicker = class;
      TOnCanUpdate = procedure(Sender: TDBDateTimePicker; 
        var Allowed: Boolean) of object;
      TDBDateTimePicker = class(TDateTimePicker)
      private
        FOnCanUpdate: TOnCanUpdate;
        procedure CMExit(var Message: TCMExit); message CM_EXIT;
      published
        property OnCanUpdate: TOnCanUpdate read FOnCanUpdate write FOnCanUpdate;
      end;
    
    procedure TDBDateTimePicker.CMExit(var Message: TCMExit);
    var
      Allowed: Boolean;
    begin      
      if Assigned(FOnCanUpdate) then
      begin
        Allowed := False;
        FOnCanUpdate(Self, Allowed);    
        if not Allowed then
        begin
          SetFocused(True);
          Exit;
        end;
      end;
    
      try
        FDataLink.UpdateRecord;
      except
        SetFocus;
        raise;
      end;
      SetFocused(False);
      inherited;
    end;
    

    So the code in the OnCanUpdate event may looks like this (note you can use this event as common for both of your date time pickers).

    procedure TForm1.DTPAddStartDateCanUpdate(Sender: TDBDateTimePicker; 
      var Allowed: Boolean);
    begin
      if (DTPAddStartDate.Date) > (DTPAddCompletionDate.Date) then
      begin
        // the Allowed parameter is in current code initialized to False
        // when it comes into this event, so the following line has no
        // sense here
        Allowed := False;
        // here you can display the error message or raise exception or just
        // whatever you want, the record won't be modified in any way
        Application.MessageBox('The completion date of a job cannot be before a ' +
          'start date. The record won''t be modified ;-)', 'Date Input Error...',
          MB_YESNO + MB_ICONSTOP + MB_TOPMOST);
      end
      else
        // only setting the Allowed to True will actually allows the record to be
        // updated, so if your validation passes, set the Allowed to True
        Allowed := True;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript datetimepicker that I downloaded online which I use to select
Downloaded IOS5 SDK yesterday, and this code which I use to set my UIToolbar's
I downloaded Axis 1.4 ( http://www.nic.funet.fi/pub/mirrors/apache.org/ws/axis/1_4/ ) and I wanted to use WSDL2Java, but
I downloaded HTTP::Daemon::SSL for Strawberry Perl 5.10 from CPAN and ran this example: use
I downloaded a mouse hook sample, which didn't work. So I stripped all the
I downloaded a binary file that was compiled (a C program) using GCC 4.4.4
have downloaded Orca to edit an MSI file. I want to remove some banner
I downloaded some code and in it was the following fragment: function GetCommentBySessionIDWCF_JSON() {
I downloaded Tomcat [7.0.22], and tried to install it. I am getting the following
I downloaded PHP 5.4 to my computer which has Windows 8 (The customer preview),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.