Hot Topic (More than 10 Replies) read only command (Read 1194 times)
debmckee
Full Member
***
Offline



Posts: 123
Joined: Oct 5th, 2011
read only command
Nov 5th, 2012 at 5:26pm
Print Post Print Post  
I have a form that I want certain fields to be read only if the form is marked as completed (with a y or n entered in a text field).  I set up the code to read only if = Y and writable if n.  The problem is that if a record is at read only and then you add a  new record the new record is also set at read only even though the complete field has an intial value of N.  The code works when you are in the record with being = to Y or N but not when you advance.  I have put the code in on form entry, tried it in form name and/or field name.
  
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 command
Reply #1 - Nov 5th, 2012 at 6:31pm
Print Post Print Post  
Show us the On Form Entry code, please.
  

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



Posts: 123
Joined: Oct 5th, 2011
Re: read only command
Reply #2 - Nov 5th, 2012 at 6:45pm
Print Post Print Post  


if  @isblank(exchange rate) then exchange rate = "1.000"

goto product code look up



if complete0 = "Y" then
{
readonly(total price per unit,1)
readonly(customs3,1)
readonly(duty3,1)
readonly(freight3,1)
readonly(fruit3,1)
readonly(handling3,1)
readonly(other3,1)
readonly(other_a2,1)
readonly(other_b3,1)
readonly(stor_fin3,1)
readonly(storage3,1)
readonly(exchange rate, 1)
readonly(fruit cost, 1)
readonly(sf cost, 1)
readonly(frt cost, 1)
readonly(customs cost, 1)
readonly(duty cost, 1)
readonly(other cost, 1)
readonly(other 1 cost, 1)
readonly(storage cost, 1)
readonly(handling cost, 1)
readonly(other 2 cost, 1)
readonly(total price per unit, 1)
readonly(po price,1)
readonly(fruit5, 1)
readonly(stor_fin5, 1)
readonly(freight5, 1)
readonly(customs5, 1)
readonly(duty5, 1)
readonly(other5, 1)
readonly(other_a5,1)
readonly(storage5,1)
readonly(handling5, 1)
readonly(other_b5, 1)

}



if complete0 = "n"  then
{

readonly(total price per unit,0)
readonly(customs3,0)
readonly(duty3,0)
readonly(freight3,0)
readonly(fruit3,0)
readonly(handling3,0)
readonly(other3,0)
readonly(other_a2,0)
readonly(other_b3,0)
readonly(stor_fin3,0)
readonly(storage3,0)
readonly(exchange rate, 0)

readonly(fruit cost,0)
readonly(sf cost, 0)
readonly(frt cost, 0)
readonly(customs cost,0)
readonly(duty cost, 0)
readonly(other cost, 0)
readonly(other 1 cost, 0)
readonly(storage cost, 0)
readonly(handling cost, 0)
readonly(other 2 cost, 0)
readonly(total price per unit, 0)
readonly(po price,0)
readonly(fruit5, 0)
readonly(stor_fin5, 0)
readonly(freight5, 0)
readonly(customs5, 0)
readonly(duty5, 0)
readonly(other5, 0)
readonly(other_a5,0)
readonly(storage5,0)
readonly(handling5, 0)
readonly(other_b5, 0)





}


                 

  
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 command
Reply #3 - Nov 5th, 2012 at 7:12pm
Print Post Print Post  
Try moving the goto line so it is the last line.
  

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



Posts: 123
Joined: Oct 5th, 2011
Re: read only command
Reply #4 - Nov 5th, 2012 at 7:14pm
Print Post Print Post  
Makes no difference.
  
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 command
Reply #5 - Nov 5th, 2012 at 7:39pm
Print Post Print Post  
Before anything else, add this line:

WriteLn(complete0)

Tell me what it says.
  

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



Posts: 123
Joined: Oct 5th, 2011
Re: read only command
Reply #6 - Nov 5th, 2012 at 8:23pm
Print Post Print Post  
Y if value is Y and N if value is N
  
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 command
Reply #7 - Nov 5th, 2012 at 8:48pm
Print Post Print Post  
What is it when you move to a new record that does not have a value yet?

(Sorry for all the questions. It's a little tough to do this blind. Smiley )
  

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



Posts: 123
Joined: Oct 5th, 2011
Re: read only command
Reply #8 - Nov 5th, 2012 at 9:03pm
Print Post Print Post  
I have a initial value of N in that field.  Plus just to make sure.......when you open form  - if that field is blank it enters N (over kill - but just in case)

It's like it doesn't recognize the value in the field when you add a new record when you are entering multiple records.  If you go into the file new - it is fine.  It  also does it properly when you search existing records.  (This is a new feature to an existing file.)
  
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 command
Reply #9 - Nov 5th, 2012 at 9:17pm
Print Post Print Post  
I know you have the initial value. I do not see you forcing the "N" in the On Form Entry code you posted.

I get that it is supposed to be N for a new record. I want to know what the writeln says so I can see if that is actually happening.
  

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



Posts: 123
Joined: Oct 5th, 2011
Re: read only command
Reply #10 - Nov 5th, 2012 at 10:12pm
Print Post Print Post  
Sorry.....I didn't understand your question until I read it again!  Which having that info.....makes me believe the problem is with my add data command.  The write(ln) doesnt even pop up when you add data from my command button but it does if you add data through the menu tree.     Everything in my files are by command button as people here don't want to use the menu tree or even see it!
I have the double command in there so you can switch to add data from the search menu.
var success as int
var vTemp as Int

     If (@Mode() = 0) Or (@Mode() = 1)
     {
           vTemp = @CreateNewRecord()
     }

                 

if @mode() = 2
{

success = @selectTreeItem("Search Menu!Switch to Add Data Mode (Ctrl-F6)")
@exit
}


  
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 command
Reply #11 - Nov 6th, 2012 at 2:28pm
Print Post Print Post  
You need to put your readonly stuff into a subroutine and call it as part of your command button code. Because you are moving between records in custom code, the events that would normally run, such as On Form Entry do not trigger.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged