Results 1 to 5 of 5

Thread: Required Field

  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Required Field

    I have a form where I need to make sure a field is not blank. The field on the form is SpecID which has a dropdown list to select initials of the person. I created a table of initials with SpecID as the Primary key. I used this key in another table and used the Lookup wizard to make a combo box of initials. Now on the form I want to make sure the people select their initials. I have tried making it a required field in the table and I have tried creating a macro that says if SpecID is Null - cancel event - display message and Gotocontrol. That doesn't work either. Is there any way to make sure this field is not blank????

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Required Field

    If you've made the field Required in your table, then you should not be able to move off the record (which causes an immediate update for a bound form) if nothing has been selected. Are you trying to prevent them from leaving that field without making a selection? I would advise against that. You can also put in code in your form's BeforeUpdate event. Check that field for IsNull, if true, then set "Cancel=True" and "Exit Sub".
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Required Field

    I attached the macro to the BeforeUpdate event of the form. When I test the field by leaving it blank, it lets me create a record even though that field is blank. I even have it as a required field in the table but I leave it blank and it lets the record go through. Does it have something to do with the fact that I used a wizard to create the dropdown list?

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Required Field

    There is a difference between blank and null (no entry). Check your field properties in your table, and make sure the Allow Zero Byte string is set to False (and required is set to True). Also, you combo box can be set to "LimitToList=True".
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Lounger
    Join Date
    Apr 2001
    Location
    Stuttgart, Germany
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Required Field

    Linda,

    It shouldn't have anything to do with the wizard. I first thought, using a macro and not an event procedure for the BeforeUpdate event could be the culprit (I never use macros for events). Now I just tested such a macro and it works. It doesn't let me save the record even if the table field is not required and the NotInList procedure is not bothering. So it must be something else. Are you sure you can save records with that field empty after editing? Existing records with SpecID empty will remain so if there is no change in the record, because neither form's BeforeUpdate nor ctlSpecID's NotInList fires then.

    Maybe you can post your macro commands here in some form, although an event procedure would be much better.

    BTW, LimitToList=True itself does allow an empty field in A97 and A2K. But you should set it anyway, otherwise the users could enter initials not contained in your table.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •