Lock record if field is not null?

S

SusanV

Hi all,

I'm trying to lock a record programmatically based on whether a certain
field has been populated. Basically, I have an Access 2000 database which is
used for tracking progress of reports in a project. Once a report is
completed and final, I do not want users to be able to alter the record in
any way. I have a main form with tab control for several subforms. All forms
involved have tables as their source. One subform (subfrmTimeline) tracks
timeline of various stages of completion, and contains a text control MMLReg
which is the date the report is final and complete. How can I set this to
lock ONLY the records where MMLReg is not null? I can't lock all records,
and this is outside of editing records, and the help, msdn and googling the
groups doesn't seem to turn anything up outside of none, all or edited.

I suppose I could lock individual controls for all forms, but that seems a
long way to go around.

TIA,

Susan
 
R

Rick Brandt

SusanV said:
Hi all,

I'm trying to lock a record programmatically based on whether a
certain field has been populated. Basically, I have an Access 2000
database which is used for tracking progress of reports in a project.
Once a report is completed and final, I do not want users to be able
to alter the record in any way. I have a main form with tab control
for several subforms. All forms involved have tables as their source.
One subform (subfrmTimeline) tracks timeline of various stages of
completion, and contains a text control MMLReg which is the date the
report is final and complete. How can I set this to lock ONLY the
records where MMLReg is not null? I can't lock all records, and this
is outside of editing records, and the help, msdn and googling the
groups doesn't seem to turn anything up outside of none, all or
edited.

I suppose I could lock individual controls for all forms, but that
seems a long way to go around.

In the Current event of the form...

Me.AllowEdits = IsNull([FieldName])

If desired, you can also have that code in the AfterUpdate of the control
bound to [FieldName] so that the record will be locked the once they make an
entry.
 
S

SusanV

Thanks Rick - one more question if you don't mind! The field I'll be
checking for null is on a subform - I want all subforms as well as the main
form to also be locked, so do I put this in the OnCurrent event of all the
forms? Or would setting this on the Main form trickle down to the subforms
in the tab control?

Thanks again!!

Susan

Rick Brandt said:
SusanV said:
Hi all,

I'm trying to lock a record programmatically based on whether a
certain field has been populated. Basically, I have an Access 2000
database which is used for tracking progress of reports in a project.
Once a report is completed and final, I do not want users to be able
to alter the record in any way. I have a main form with tab control
for several subforms. All forms involved have tables as their source.
One subform (subfrmTimeline) tracks timeline of various stages of
completion, and contains a text control MMLReg which is the date the
report is final and complete. How can I set this to lock ONLY the
records where MMLReg is not null? I can't lock all records, and this
is outside of editing records, and the help, msdn and googling the
groups doesn't seem to turn anything up outside of none, all or
edited.

I suppose I could lock individual controls for all forms, but that
seems a long way to go around.

In the Current event of the form...

Me.AllowEdits = IsNull([FieldName])

If desired, you can also have that code in the AfterUpdate of the control
bound to [FieldName] so that the record will be locked the once they make
an
entry.
 
S

SusanV

Got them all done via the main form using Me!subform.Locked = not
isnull([mmlreg])

Thanks again Rick

SusanV said:
Thanks Rick - one more question if you don't mind! The field I'll be
checking for null is on a subform - I want all subforms as well as the
main form to also be locked, so do I put this in the OnCurrent event of
all the forms? Or would setting this on the Main form trickle down to the
subforms in the tab control?

Thanks again!!

Susan

Rick Brandt said:
SusanV said:
Hi all,

I'm trying to lock a record programmatically based on whether a
certain field has been populated. Basically, I have an Access 2000
database which is used for tracking progress of reports in a project.
Once a report is completed and final, I do not want users to be able
to alter the record in any way. I have a main form with tab control
for several subforms. All forms involved have tables as their source.
One subform (subfrmTimeline) tracks timeline of various stages of
completion, and contains a text control MMLReg which is the date the
report is final and complete. How can I set this to lock ONLY the
records where MMLReg is not null? I can't lock all records, and this
is outside of editing records, and the help, msdn and googling the
groups doesn't seem to turn anything up outside of none, all or
edited.

I suppose I could lock individual controls for all forms, but that
seems a long way to go around.

In the Current event of the form...

Me.AllowEdits = IsNull([FieldName])

If desired, you can also have that code in the AfterUpdate of the control
bound to [FieldName] so that the record will be locked the once they make
an
entry.
 
Top