Required fields

  • Thread starter Thread starter TeeSee
  • Start date Start date
T

TeeSee

For whatever reason (bad programming is a great possibility) I have
fields in my database that do not conform to underlying "required
field" requirements. Sorry, must have been in the eary learning
stages.

Now, obviously when updating a field within one of these records, I
receive as many error messages as ther are fields that don't conform.
Could you suggest code for the form open event that can check for
those fields and allow correction prior to the code actually
"breaking"

Hopefully thanks
 
TeeSee,

Umm, what do the error messages say? And what do you mean by "...do not
conform..."? You say when you are updating the field of one of the records,
is it numberic and you are trying to add text? Going to need more
information.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
For whatever reason (bad programming is a great possibility) I have
fields in my database that do not conform to underlying "required
field" requirements. Sorry, must have been in the eary learning
stages.

Now, obviously when updating a field within one of these records, I
receive as many error messages as ther are fields that don't conform.
Could you suggest code for the form open event that can check for
those fields and allow correction prior to the code actually
"breaking"

Hopefully thanks

If the problem is that you're trying to set a field to be Required, the
offending records have NULL in the field. To find them create a query based on
the table and put

IS NULL

(just like that, no quotes) on the criteria line.

If that's not the error... do as my friend Gina requests and post some more
information.
 
If the problem is that you're trying to set a field to be Required, the
offending records have NULL in the field. To find them create a query based on
the table and put

IS NULL

(just like that, no quotes) on the criteria line.

If that's not the error... do as my friend Gina requests and post some more
information.

Thanks Gina and John for responding. By "conform" I was meaning that
the required field(s) dindn't have data in them.

Let me try to be more clear ....

a record is presented on a form for editing. Lets say there are ten
fields on it and other than the PK one field is "required" by the
underlying table. I edit two of the fields but don't think to udate
the required field which is either null or "" (Haven't figured that
out yet).
So when I try to save the edits the code at the moment breaks into
debug mode stating that can't save record while no data in the
required field.

Am wondering how to code properly to trap that error and to set focus
to the offending field. Hope this is more understandable.

Thanks again
 
a record is presented on a form for editing. Lets say there are ten
fields on it and other than the PK one field is "required" by the
underlying table. I edit two of the fields but don't think to udate
the required field which is either null or "" (Haven't figured that
out yet).
So when I try to save the edits the code at the moment breaks into
debug mode stating that can't save record while no data in the
required field.

Please post your code. I take it that you're using VBA code to save the data
from the form to a table, rather than using a (much simpler!) bound form? If
so, the check would have to be done in your code, with something resembling

If IsNull(Me![requiredfield]) Then
MsgBox "You need to fill in requiredfield!", vbOKOnly
Me![requiredfield].SetFocus
Exit Sub
End If

but the details will of course depend on your code.
 
a record is presented on a form for editing. Lets say there are ten
fields on it and other than the PK one field is "required" by the
underlying table. I edit two of the fields but don't think to udate
the required field which is either null or "" (Haven't figured that
out yet).
So when I try to save the edits the code at the moment breaks into
debug mode stating that can't save record while no data in the
required field.

Please post your code. I take it that you're using VBA code to save the data
from the form to a table, rather than using a (much simpler!) bound form?If
so, the check would have to be done in your code, with something resembling

If IsNull(Me![requiredfield]) Then
   MsgBox "You need to fill in requiredfield!", vbOKOnly
   Me![requiredfield].SetFocus
   Exit Sub
End If

but the details will of course depend on your code.

Hello again John. The form is in fact bound and the records with
required fields that are blank are not a problem until I edit one of
those records and try to save it. Your last response has given me the
path to the solution.

Thanks again
 
Private Sub txtName_Exit(Cancel As Integer)
If IsNull(Me![txtName]) Then
MsgBox "You need to fill in requiredfield!", vbOKOnly
Me![txtName].SetFocus
End
End If
End Sub


TeeSee said:
a record is presented on a form for editing. Lets say there are ten
fields on it and other than the PK one field is "required" by the
underlying table. I edit two of the fields but don't think to udate
the required field which is either null or "" (Haven't figured that
out yet).
So when I try to save the edits the code at the moment breaks into
debug mode stating that can't save record while no data in the
required field.

Please post your code. I take it that you're using VBA code to save the data
from the form to a table, rather than using a (much simpler!) bound form? If
so, the check would have to be done in your code, with something resembling

If IsNull(Me![requiredfield]) Then
MsgBox "You need to fill in requiredfield!", vbOKOnly
Me![requiredfield].SetFocus
Exit Sub
End If

but the details will of course depend on your code.

Hello again John. The form is in fact bound and the records with
required fields that are blank are not a problem until I edit one of
those records and try to save it. Your last response has given me the
path to the solution.

Thanks again
 
Back
Top