• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Making a field required

I have a date field in both sql server and MIcrosoft access databases that  needed now to be converted to a required fiield. It was'nt before.
What would happen to the table if I convert this to be required  and for rows that were left null previousl to convert it? would the table accept the changes?
0
zachvaldez
Asked:
zachvaldez
  • 2
  • 2
  • 2
  • +4
1 Solution
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
It will not allow you to do so if you have null values in the column.
What you can do is update null to some default value and then you will be able to make them required/not null
0
 
athomsfereCommented:
Exactly as IJZ said.

You can make it default value.
0
 
zachvaldezAuthor Commented:
What appropriate default date value to enter  since many rows were ignored and left blank for years?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Please provide some discription
but in general you can use empty string or space for text data
0 for numeric
0/false/no for bool
and for datetime you may use some old native date or timestamp filed if there is in the table
0
 
Dale FyeCommented:
If all the data is being entered via Access forms, another way to do this would be to modify the form and place a check in the BeforeUpdate event to identify if the field is a valid date, and if not, force the user to enter a date before saving the current record.
0
 
Mohamed AbowardaSoftware EngineerCommented:
You don't have to set a value for the field you want to make required, leave the database as it is (don't change the field), and simply check when you execute INSERT sql statement if the field is not null, if null you can show error message and don't insert.
0
 
zachvaldezAuthor Commented:
it has to be isdate and i null for checking. IN access form should this be in the form_beforeupdate event?
0
 
UnifiedISCommented:
I would look to make the requirements on the application side instead of disallowing nulls.  
Your application will still need to ensure the data follows any business rules.  It's easier to consume nulls on outputs also because it is not specific to a data type like if you put in blank space for a text field and a really old date for a datetime field.
0
 
Mohamed AbowardaSoftware EngineerCommented:
If you used database required attribute, you MUST enter a value, the value first in the null fields, the value will depend on the field usage, that's why I recommend you to keep the database as it's without changing the field to required, and make the field required from your application when the user try to insert a new row not your database.
0
 
Alpesh PatelAssistant ConsultantCommented:
It will not save the converted changes. It will ask to drop table and create again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now