Hot Topic (More than 10 Replies) [Solved] Make form conditionally read only (Read 2102 times)
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
[Solved] Make form conditionally read only
Oct 29th, 2007 at 8:24pm
Print Post Print Post  
I'm looking to make a entire form layout read only for an @Group "User"  then make it read only for @Group "Management" after 45days from @date. and Admin will have total access.

How would I write a ReadOnly to the entire layout? without having to write every LE? being picky (I dont want it grayed out, just not changeable)

Thank you
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Read Only qestion
Reply #1 - Oct 29th, 2007 at 8:33pm
Print Post Print Post  
Assuming version 2, try something like this On Form Entry:

Code
Select All
#include "sbasic_include.sbas"
var vList as String
var vGroup as String

	vGroup = @Group
	vList = @StringArrayElementList()
	If (vGroup = "User") Or ((vGroup = "Management") And (@ServerDate() >= (DateAdded + 45)))
	{
		StringArrayAttributes(vList, ATTR_ID_READ_ONLY, "2")
	}
	Else
	{
		StringArrayAttributes(vList, ATTR_ID_READ_ONLY, "0")
	}
 




  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Read Only qestion
Reply #2 - Oct 29th, 2007 at 8:57pm
Print Post Print Post  
very nice! and works well!! and doesn't every run 2.0.3?  Grin
Thank you yet again
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
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: [Solved] Make form conditionally read only
Reply #3 - Oct 30th, 2007 at 12:10pm
Print Post Print Post  
Erika, I'm just curious as to why you use a variable instead of @Group() directly.  Is it faster?
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Make form conditionally read only
Reply #4 - Oct 30th, 2007 at 12:42pm
Print Post Print Post  
Infinity wrote on Oct 30th, 2007 at 12:10pm:
Erika, I'm just curious as to why you use a variable instead of @Group() directly.  Is it faster?


Yes. Asking for the variable value is faster than calling @Group multiple times.
  

- 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: [Solved] Make form conditionally read only
Reply #5 - Oct 30th, 2007 at 12:50pm
Print Post Print Post  
Interesting, thank you.  I use @Group and @UserId checks in a number of places.  Would it make things a bit faster if I set static variables in Global Code and then did my checks against the statics?  I'm thinking:
Code
Select All
Stat sGroup as String = @Group
Stat sUser as String = @UserID 


  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Make form conditionally read only
Reply #6 - Oct 30th, 2007 at 1:35pm
Print Post Print Post  
Infinity wrote on Oct 30th, 2007 at 12:50pm:
Interesting, thank you.  I use @Group and @UserId checks in a number of places.  Would it make things a bit faster if I set static variables in Global Code and then did my checks against the statics?


Never initialize statics as part of the declaration.

Code
Select All
stat sGroup as String
stat sUser as String

    sGroup = @Group
    sUser = @UserID
 

  

- 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: [Solved] Make form conditionally read only
Reply #7 - Oct 30th, 2007 at 4:26pm
Print Post Print Post  
Thank you, I forgot that.  I've seen it elsewhere and I'm afraid it's become habit.

Do the initializations have to come before the subroutines and functions, or after, or does it not matter?
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Make form conditionally read only
Reply #8 - Oct 30th, 2007 at 7:53pm
Print Post Print Post  
Infinity wrote on Oct 30th, 2007 at 4:26pm:
Thank you, I forgot that.  I've seen it elsewhere and I'm afraid it's become habit.

Do the initializations have to come before the subroutines and functions, or after, or does it not matter?


They are executable code, so they come after all declarations, including subroutine/function declarations.
  

- 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: [Solved] Make form conditionally read only
Reply #9 - Oct 31st, 2007 at 1:37pm
Print Post Print Post  
Thank you, I'll remember that.  If I put the initializations into an _include.sbas file, I assume I have to call the #include after all the declarations as well?  (I ask because I've only ever seen the #include calls at the top of code.)
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Make form conditionally read only
Reply #10 - Oct 31st, 2007 at 2:03pm
Print Post Print Post  
Infinity wrote on Oct 31st, 2007 at 1:37pm:
Thank you, I'll remember that.  If I put the initializations into an _include.sbas file, I assume I have to call the #include after all the declarations as well?  (I ask because I've only ever seen the #include calls at the top of code.)


#include is just like pasting the including code where the #include appears. It follows the same rules. Where it goes depends on the content of the included file.
  

- 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: [Solved] Make form conditionally read only
Reply #11 - Oct 31st, 2007 at 2:30pm
Print Post Print Post  
Thank you!
  

**
Captain Infinity
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: [Solved] Make form conditionally read only
Reply #12 - Nov 6th, 2007 at 4:44pm
Print Post Print Post  
ok, this doesn't work in the application but works great in preview. I have removed the ReadOnly(Command Buttons, 0) and still get the same thing.

It gets a runtime SBasic error only in the application.

Does anyone see a mistake?

Code
Select All
// Hide-Show Command Buttons Based on Mode 0=Add, 1=Update, 2=Retrieve and Do Not Enter Extend Mode

#include "sbasic_include.sbas"
var vList as String
var vGroup as String
vGroup = @Group
vList = @StringArrayElementList()

If @Mode() = 0
{
	Visibility(Header1,0)
	Visibility(Header2,0)
	Visibility(Prev_Record, 1)
	Visibility(Save_Exit, 1)
	Visibility(Add_Data, 1)
	Visibility(Search, 1)
	Visibility(Reports, 0)
	Visibility(Print_Form, 1)
	Visibility(Next_Record, 1)
	Visibility(Retrieve Records, 0)
	Visibility(Sort Records, 0)
	Visibility(Clear Specs, 0)
	Visibility(View As Table, 0)
	Visibility(Calc0,1)
	Visibility(Calc,0)
}
If @Mode() = 1 Then
	{

		If ((vGroup = "User") And (@ServerDate() >= (Call_Date + 45)))
			{
				StringArrayAttributes(vList, ATTR_ID_READ_ONLY, "2")

			}
		Else
			{
				StringArrayAttributes(vList, ATTR_ID_READ_ONLY, "0")
			}

		If (@ResultSetCurrentPosition() = @ResultSetTotal())
			{
				NotifyForm(2)
			  }
		ELSE
			{
				NotifyForm(-2)
			  }
		If @IsBlank(SFP)
				{
					SFP = "SFP"
				}
		Visibility(Header1,0)
		Visibility(Header2,0)
		Visibility(Prev_Record, 1)
		Visibility(Save_Exit, 1)
		Visibility(Add_Data, 1)
		Visibility(Search, 1)
		Visibility(Reports, 1)
		Visibility(Print_Form, 1)
		Visibility(Next_Record, 1)
		Visibility(Retrieve Records, 0)
		  Visibility(Sort Records, 1)
		Visibility(Clear Specs, 0)
		Visibility(View As Table, 1)
		Visibility(Calc0,0)
		Visibility(Calc,1)
	}

ThrowFocus(Company_Name)



 

  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] Make form conditionally read only
Reply #13 - Nov 6th, 2007 at 4:47pm
Print Post Print Post  
What is the Start In: directory for Sdesigner set to?
What is the Start In: directory for Sesame set to?

It may be that the Sesame program can not find the sbasic_include.sbas file to include but Preview mode can.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: [Solved] Make form conditionally read only
Reply #14 - Nov 6th, 2007 at 6:03pm
Print Post Print Post  
oooohhhh,
C:\Sesame2  for Sdesigner and then C:\Sesame2\data for Sesame.
Fixed it!
Thank you Ray
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: [Solved] Make form conditionally read only
Reply #15 - Nov 10th, 2007 at 3:45am
Print Post Print Post  
Hello Ray
I'm having the same issue now with another batch of code from Sept 07's "Inside Sesame" on Popup Dialogs. It works well GREAT in preview but I get the runtime error in the Application.

Quote:
What is the Start In: directory for Sdesigner set to?
What is the Start In: directory for Sesame set to?

It may be that the Sesame program can not find the sbasic_include.sbas file to include but Preview mode can.

I checked that they are both the same. (This time) Thats what was wrong with the last error. Where should I look next?
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] Make form conditionally read only
Reply #16 - Nov 12th, 2007 at 9:38pm
Print Post Print Post  
Hello Flip,

Next thing I would look at is to be sure that you reconciled the correct DB file. Or possibly even save the DSR file as a new DB and see if it compiles. Other than the Start In: being different I can not think of what would cause that.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: [Solved] Make form conditionally read only
Reply #17 - Nov 13th, 2007 at 2:02am
Print Post Print Post  
Thank you Ray,
mute point now, I had a break in over the weekend and lost all the company computers. They stole the safes with the back ups, other info and all the software licenses. They trashed the offices, its been difficult. I do have a key drive back up I carry with the db backed up on Friday and only lost about 8 hours of programing. Let me clarify that, that would be a lot for you or anyone else, for me it was about three lines. Lucky today is a holiday and we are closed.

Reminder, Back up your stuff! REMOTELY!!!

I'll be back!

Flip
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] Make form conditionally read only
Reply #18 - Nov 13th, 2007 at 2:26am
Print Post Print Post  
Shocked  Oh, Flip, that's awful! Have you sent in your databases to Support for anything lately? If so, they may still have a copy...
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: [Solved] Make form conditionally read only
Reply #19 - Nov 13th, 2007 at 2:43am
Print Post Print Post  
Thank you Erika!
I'm good, my data entry person backs up the database to her key drive every night! I have a copy of the database.
But a REALLY good idea! (not using you for an off site backup, but for the above and beyond help and support you all provide) 
I'm down, but not out!
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged