A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old October 18th, 2007, 02:49 PM posted to microsoft.public.access.forms
Mario
external usenet poster
 
Posts: 115
Default How to make the form read only when field status is CLOSED

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

  #2  
Old October 18th, 2007, 04:10 PM posted to microsoft.public.access.forms
Carl Rapson
external usenet poster
 
Posts: 517
Default How to make the form read only when field status is CLOSED

"Mario" wrote in message
...
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


  #3  
Old October 18th, 2007, 07:19 PM posted to microsoft.public.access.forms
Pieter Wijnen
external usenet poster
 
Posts: 1,354
Default How to make the form read only when field status is CLOSED

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

"Carl Rapson" wrote in message
...
"Mario" wrote in message
...
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




  #4  
Old October 19th, 2007, 05:15 PM posted to microsoft.public.access.forms
Mario
external usenet poster
 
Posts: 115
Default How to make the form read only when field status is CLOSED

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

"Carl Rapson" wrote:

"Mario" wrote in message
...
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



  #5  
Old October 19th, 2007, 05:16 PM posted to microsoft.public.access.forms
Mario
external usenet poster
 
Posts: 115
Default How to make the form read only when field status is CLOSED

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

"Pieter Wijnen" wrote:

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

"Carl Rapson" wrote in message
...
"Mario" wrote in message
...
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





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.