Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Custom validation on a date field won't work

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom validation on a date field won't work

    I have an asset register application with an ASSET table that includes two fields: a DATEACQUIRED (the date when the asset was acquired) and a DATESOLD (the date when it was sold, unless the asset is still owned then this date will be nil).

    In the ASSET table, I want a field rule for DATESOLD to make sure it is not entered with a value less than DATEACQUIRED. But a nil date is OK indicating the asset is still owned.

    So my custom validation for DATESOLD looks like this:

    Validation: DATESOLD"{01/01/0001} .OR. .NOT.(BETWEEN(DATESOLD,{01/01/0001},DATEACQUIRED))
    Error message: Date sold must not be prior to date acquired

    My problem is that whatever date I enter for DATESOLD I always get the error message. For example:

    DATEACQUIRED = 04/04/2003
    DATESOLD = 12/12/2003

    Yes, this gives the error message when it shouldn't!

    I have tried several different validation formulae to try and solve this problem but I always get the error message whatever the value of DATESOLD. (But it's interesting to note that the expression builder interim result displays the correct result).

    Does anyone have a solution that will work, for example that accepts the above example as valid but will reject a DATESOLD of 03/03/2003 as invalid?

    #2
    RE: Custom validation on a date field won't work

    Try:

    Code:
    IF(len(alltrim(dtos(DateSold))) = 0, .T., IF(DateSold >= DateAcquired, .T., .F.))
    Field values that evaluate as .T. will be accepted, .F. will be trapped.

    -- t

    Comment


      #3
      RE: Custom validation on a date field won't work

      Brett,
      Try this for the custom validation in the field rule for DATESOLD
      IIF(ISBLANK("DATESOLD"),.T.,IIF("DATESOLD")"=("DATEACQUIRED"),.T.,.F.))

      It seems to work in my application.

      Dick Blanchard

      Comment


        #4
        RE: Custom validation on a date field won't work

        Brett,
        This works
        IF(ISBLANK("DATESOLD"),.T.,IF(DATESOLD"=DATEACQUIRED,.T.,.F.))

        You don't need all the parenthesis and quotes I put above.

        Dick

        Comment


          #5
          RE: Custom validation on a date field won't work

          Thanks guys, great work! This is a much better way of doing it.

          Comment


            #6
            RE: Custom validation on a date field won't work

            Whoops, I spoke too soon. I have tried both suggestions and still get the same problem as I originally had and could not resolve. That is to say whatever value I try and place in the DATESOLD field in my ASSET table, I always get the same custom validation error.

            DATESOLD can be nil, less than or greater than the DATEACQUIRED, I always get this error.

            I have attached two JPEG screen snaps: one the custom validation for DATESOLD and the other showing the field values and error message.

            Any suggestions?

            Comment


              #7
              RE: Custom validation on a date field won't work

              Second JPEG screen snap attached.

              Comment


                #8
                RE: Custom validation on a date field won't work

                Now here's something interesting I have just noticed.

                If I edit the DATESOLD field in the ASSET table directly, the custom validation check works correctly. It's only when I edit the same field in a form (attached to the ASSET table) that I get this problem. I can't work out why this should be a problem.

                Comment


                  #9
                  RE: Custom validation on a date field won't work

                  Brett,

                  The expression I gave was tested before I posted it. Here's a working model. Unzip and extract contents to an empty folder.

                  There are at least two different ways to validate inputs of this type. (1) use a custom validation field rule expression, as I have done; or (2) attach a validation script to the OnDepart event of the DateSold field object in the data entry form. This latter course would involve a different script, obviously.

                  One should not do both. Is this possibly what's happened?

                  -- t

                  Comment


                    #10
                    RE: Custom validation on a date field won't work

                    Thanks, Tom. I have downloaded your Zip file and will check it out. No, I have not done both the things you mention - I have a custom validation rule for the DATESOLD field, but nothing else. So I am really scratching my head on this one, it's really perplexing. The thing I have just noticed is that the custom validation works correctly when I edit the ASSET table directly. It's only on the form that the problem occurs.
                    If I can't get to the bottom of the problem I will try your suggestion #2.

                    Comment


                      #11
                      RE: Custom validation on a date field won't work

                      Brett if it works correctly using the default form for the table that pretty much rules out errors in the way you've implemented it in field rules. The trouble most likely lies in the custom data entry form.

                      Are you by any chance entering DateSold before there's any value in DateAcquired?

                      All my testing here assumes your data entry person would enter DateAcquired first.

                      -- t

                      Comment


                        #12
                        RE: Custom validation on a date field won't work

                        In testing just now if I skip DateAcquired (leaving it empty), and enter a value in DateSold the custom validation field rule does NOT throw an error. If I then enter a value in DateAcquired and save the field rule correctly checks the two dates and throws the error when it should. So, my guess about your data entry sequence is probably not going to be helpful after all. Sorry. -- t

                        Comment


                          #13
                          RE: Custom validation on a date field won't work

                          I finally worked the problem out! I took your sample application, Tom, determined to build up my asset application step by step until the same custom validation error occurred. After doing this I found that it worked perfectly using your validation code - no problem at all! So I went back to my application and tried to discover why the same validation code didn't work in one case and did in the other. And then I discovered a copy of my original custom validation code in a completely unrelated field! I think what has happened is that I had inadvertently copied the old code there a few weeks ago when I was first having problems. So I have deleted the old code and everything now works correctly. Thanks for your help, Tom, (and Richard too), sorry to waste your time. But I'm ecstatic now that it's finally fixed!

                          Comment

                          Working...
                          X