Normal Topic [Solved] Set "Read Only" elements based on date? (Read 1806 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
[Solved] Set "Read Only" elements based on date?
Oct 4th, 2007 at 8:57pm
Print Post Print Post  
Is it possible to make a Read Only element writable if the Invoice_Date element falls within the current month?

What I'm trying to do is "lock in" invoice values once the month changes, so no one can go back and muck with the sales figures once they've been booked to our accounting system.  During the current month they can do whatever they like.

I have no problem with the ReadOnly() command, it's the test against this month that has me puzzled.
I tried this with no success:
Code
Select All
// Sets the breakout elements to writable for Admin, and other users within the current month

IF ( ( @MONTH(Invoice_Date) = @MONTH(@Date)) AND (@YEAR(Invoice_Date) = @YEAR(@Date) ) OR (@Group = "Admin") )
THEN
	{
	ReadOnly(Portion_Rigging, 0)
	ReadOnly(Portion_Trans, 0)
	ReadOnly(Portion_Crane, 0)
	ReadOnly(Portion_Storage, 0)
	ReadOnly(Portion_Heli, 0)
	} 



Thanks in advance for any pointers.
« Last Edit: Oct 5th, 2007 at 1:51pm by Hammer »  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Set "Read Only" element writable based on date
Reply #1 - Oct 5th, 2007 at 12:20am
Print Post Print Post  
That makes them writable,
but you need to add an

ELSE ....ReadOnly = 1 section.

This code is in On Form Enter, correct?

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Set "Read Only" element writable based on date
Reply #2 - Oct 5th, 2007 at 12:22am
Print Post Print Post  
Scott,

I think you may have parentheses issues in your conditional and you are not checking the combinations you think you are checking.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Set "Read Only" element writable based on date
Reply #3 - Oct 5th, 2007 at 10:49am
Print Post Print Post  
Thanks Bob & Erika, you were both right and I've got it working now.  Yay!
  

**
Captain Infinity
Back to top
IP Logged
 
Alec
Lanticans
*****
Offline



Posts: 200
Location: Ascot, England, UK
Joined: Nov 22nd, 2002
Re: Set "Read Only" element writable based on date
Reply #4 - Oct 5th, 2007 at 11:09am
Print Post Print Post  
There's another issue. What you don't want to do is to make fields not read-only on a record that is read-only because of network record locking. You'll need to check on this first. To do so, check the readonly status of an element that is normally always editable. If it's locked, then the record is locked because of multi-user record locking. You then don't want to make any fields not read-only.
  

Alec
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Set "Read Only" element writable based on date
Reply #5 - Oct 5th, 2007 at 11:58am
Print Post Print Post  
Thanks you Alec, I hadn't thought of that!
  

**
Captain Infinity
Back to top
IP Logged
 
Alec
Lanticans
*****
Offline



Posts: 200
Location: Ascot, England, UK
Joined: Nov 22nd, 2002
Re: Set "Read Only" element writable based on date
Reply #6 - Oct 5th, 2007 at 5:17pm
Print Post Print Post  
Infinity wrote on Oct 5th, 2007 at 11:58am:
Thanks you Alec, I hadn't thought of that!


Yes, this caught me out recently. If I've the choice, I prefer to use Visibility to hide elements, rather than use readonly. It's less problematic. If you want to show what has been entered, and is now locked, then you've no choice.
  

Alec
Back to top
IP Logged