How to make the form read only when field status is CLOSED

G

Guest

I have a DB of Issues, there is a field Status (Active Closed Resolved).
I need when a person change the STATUS field to CLOSE to automatticaly set
the Edit to "NO" so the fields in the form would show in Read Only, BUT leave
the field STATUS open for edits to Reopen the Issue. I may have an idea how
to do that but don't know how to coded, can these be done with a macro or VB
code. Can somebody give me some direction?
Tks in advance.
Mario
 
C

Carl Rapson

Mario said:
I have a DB of Issues, there is a field Status (Active Closed Resolved).
I need when a person change the STATUS field to CLOSE to automatticaly set
the Edit to "NO" so the fields in the form would show in Read Only, BUT
leave
the field STATUS open for edits to Reopen the Issue. I may have an idea
how
to do that but don't know how to coded, can these be done with a macro or
VB
code. Can somebody give me some direction?
Tks in advance.
Mario

Since you want to lock all but a single field you'll need to loop through
all controls on the form and set each one's Locked property to True. Create
a sub procedure something like this:

Sub LockControls(bLock As Boolean)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "Lock" Then
ctl.Locked = bLock
End If
Next ctl
End Sub

For each control you want locked, enter the text "Lock" (without the quotes)
into the Tag property. Then, in the AfterUpdate event of the STATUS field,
call LockControls and pass the appropriate Boolean value:

If Me.STATUS = "CLOSE" Then
LockControls True
Else
LockControls False
End If

Carl Rapson
 
P

Pieter Wijnen

you'd want to add
on error resume next
to that one, as some controls don't have a locked property, but can be
ignored for that very same reason

Pieter
 
G

Guest

Carl;
Your suggestion works for me, i also add the Pieter suggestion for error rtn.
Tks guys.
 
G

Guest

Pieter;
Tks for the that detail, i need it!

Pieter Wijnen said:
you'd want to add
on error resume next
to that one, as some controls don't have a locked property, but can be
ignored for that very same reason

Pieter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top