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

Default a date field to NULL or EMPTY...

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

    Default a date field to NULL or EMPTY...

    Any Idea how to default a date field in a table to NULL. I would like it to store nothing as opposed to "/ /".

    The help file showes the following:

    NULL_VALUE() is used in an Update Operation or an Xbasic script to assign null to a field or variable of any type.

    However when I try to use it to default a data field in my database to NULL in the expression builder it returns an error when I click OK. The error states "Expression does not evaluate to a Date value". and will not let it be used. Though it is not flagged as "invalid or incomplete" within the expression builder.

    Any ideas?

    Cheers.

    #2
    RE: Default a date field to NULL or EMPTY...

    Chuck, I recommend you use a dummy date to populate the field. A date that will never be used in the app. Leaving the field empty saves no disk space. The DBF format will still store 8 blank spaces there for each null date type field. Rather than fight the subtle nuances of empty vs. blank vs. null, I frequently use 01/01/1900. I can test for this specific date as easily as any other, and as easily as testing to see if the field is blank. -- t

    Comment


      #3
      RE: Default a date field to NULL or EMPTY...

      From the documentation....

      Null Table Field Values

      Alpha Five does not really have the concept of a NULL value for a table field value. If you want to test if the field is empty, then you use these expressions:

      Character

      "fieldname" = ""


      Date

      "fieldname" = ctod("")


      Numeric

      You cannot distinguish between records that have no value, and those that have a 0 in them.

      "fieldname" = 0


      Logical

      You cannot distinguish between records that have no value, and those that have a .f. value.

      "fieldname" = .f.


      Time

      "fieldname" = 00/00/0000 12:00:00 00 am


      Short Time

      "fieldname" = 12:00:00 00 am


      Supported By

      Alpha Five Version 5 and Above
      There can be only one.

      Comment


        #4
        RE: Default a date field to NULL or EMPTY...

        I do not care to test that the value is empty at this point. This is more of a house keeping issue. If nothing was entered then nothing should be there when the record is queried.

        From the documentation....

        NULL_VALUE() is used in an Update Operation or an Xbasic script to assign null to a field or variable of any type.

        Seems like to "a field or variable of any type" should cover the date type of field or any type?

        I am stuck with the same issue for numeric fields. Hopefully everyone agrees that 0 is not nothing in terms of a numeric value yet when nothing is entered, 0 is what is returned from the numeric field. I would like to see nothing returned in say a grid field when nothing was intended in the database field it is representing.

        Thanks,

        Comment


          #5
          RE: Default a date field to NULL or EMPTY...

          Chuck,

          As you correctly stated, the documentation says that:
          Code:
          NULL_VALUE() is used in an [b]Update Operation[/b] or an Xbasic script to assign null to a field or variable of any type.
          However, you also say that you plan to "use it to default a data field in my database". Are you specifically using an Update Operation?

          Steve

          Comment


            #6
            RE: Default a date field to NULL or EMPTY...

            Chuck:
            This question has been asked on the forum before. Run a search and you will find several suggestions.
            Here is one more:
            topparent:Date_field_name.text = ""
            Gabe

            Comment


              #7
              RE: Default a date field to NULL or EMPTY...

              Thanks for your replies,

              I have tried the Update Operations available from the Operations tab in the control panel. The blanking of fields and the use of NULL.VALUE() is only available for text fields which seem contrary to the documentation as I currently understand it (which is not much I am finding).

              The expression builder in the Operations builder gives the same error listed in my original post.

              Cheers,

              Comment


                #8
                RE: Default a date field to NULL or EMPTY...

                Thanks,

                I did search first and did not find the results satisfactory so I thought I would start another thread.

                Cheers,

                Comment


                  #9
                  RE: Default a date field to NULL or EMPTY...

                  Ok

                  From reading other threads is seems that the equivalent to a NULL value for a numeric field is 0 -zero- and NULL for a date field is "/ /".

                  SO my new question. How do you folks keep from returning these Null like characters in the fields of a grid used to view the records in your database. I am talking Web Projects type grid here.

                  The Alpha folks cannot intend that we for example accept 0 in a numeric field when no number was intended for that field in that record. If the field was intended to track a number that could be -zero- when measured that is altogether different than not having measured in the first place. In which case Alpha5 forces -zero- anyway.

                  It seems that the only solution is to use txt fields if you want a blank field. Then you are limited to no numeric or date operations within your data table.

                  Thai seems too like way to big a limitation in Alpha5 for such a large following of users so I am sure I am wrong and that the answer is out there somewhere!?

                  Cheers,

                  Comment


                    #10
                    RE: Default a date field to NULL or EMPTY...

                    ""It seems that the only solution is to use txt fields if you want a blank field""
                    Not so:
                    In a numeric field, in the field properties, format it to show: number, blank if zero or currency, blank if zero and so on
                    In a date field, if you follow the script I sent you, it will be blank. If you have a date field in a form and skip it, it will remain blank.
                    Gabe

                    Comment


                      #11
                      RE: Default a date field to NULL or EMPTY...

                      Thanks,

                      I have used the display format property for the field label control and it does hide the 0. I am still trying to get around the mathmatical problems this introduces though as the zero is i fact there in the database even though no data was entered. My current work around is to provide a checkbox for the person to indicate if they have data for the numeric field. If True then I can use it, if False I do not.

                      I am trying you script for the date field label. Thanks.

                      Chuck

                      Comment


                        #12
                        RE: Default a date field to NULL or EMPTY...

                        Chuck:
                        I am not quite sure, mathematically speaking, what is the difference between a blank field and a field that has a zero??
                        Are there any instances where this could create any mis-calculations?? Or are you concerned with queries?
                        I am speaking of numeric fields. Ofcourse a blank date has no calculable value.
                        If there is a possibiility of mathematical error, you could write a scripe that will blank out the field. But I am currious, when would that be necessary ??

                        Gabe

                        Comment


                          #13
                          RE: Default a date field to NULL or EMPTY...

                          I think what Chuck is talking about really isn't a mathematical thing at all. It's really a logical way of looking at data and is quite common in databases, especially SQL based one's. A numeric field that has a 0 in it for example is definitely not always treated the same as when it has a null value in it. A value of 0 means that the numeric field is a zero, whereas null means it is unknown. This is true of dates, etc.
                          Now it is true that in most SQL based databases if you add a bunch of fields together and one of them has a null value, then the result is null. Sort of the sum of the numbers, but if one is unknown, then the result is unknown.
                          To solve this problem if you want to differentiate between null and 0, I think I would tend to add a field behind the scenes, that indicates that the field is really null, and maybe add logic to the normal field to confirm that if the person puts a 0 in it, whether they mean 0 or null.
                          Hope this helps clarify things a little bit.
                          Alan

                          Comment


                            #14
                            RE: Default a date field to NULL or EMPTY...

                            The real issue is the validity of the data in the numeric field. There is any number of reasons to accept the value in a database table�s field as 0 that could be both valid and useful information even and especially as the result of a mathematical expression. A blank or NULL that forces the table to store a numeric 0 in a field that is used to evaluate a real number is forcing an invalid expression of 0 in this context.

                            Take for example you are using the �alltrim(str("value",250,2,"B"))� in a Display format for a textbox or label field in your grid. If you use the Hide if Blank (�B�) formatting when displaying your numeric data fields you are assuming that there is never an instance when that field may actually be 0 �zero-. This is a problem as a numeric field is to represent the set of all real numbers {-infinity " 0 " infinity}. Since 0 is a valid real number how can it also serve as a valid NULL or BLANK set.

                            Chuck

                            Comment


                              #15
                              RE: Default a date field to NULL or EMPTY...

                              I see your point. It all depends on your app. You might want to take advantage of isblank() and not.isblank().
                              Gabe

                              Comment

                              Working...
                              X