Normal Topic Re-naming an element (Read 1658 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re-naming an element
Jan 11th, 2016 at 9:49pm
Print Post Print Post  
I know it can be done, but don't know how to do it.

I need to change the label of an element, and maybe the background color depending on what is in the element.

Would someone explain how this is done?

Thanks!

  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Re-naming an element
Reply #1 - Jan 11th, 2016 at 11:09pm
Print Post Print Post  
Ready and ePrescription are the elements and Labels. Here the Label and background color are changed conditionally. Hope this may help.

Code
Select All
If @IsNew and D1 = "" then
	{
		Attribute (Ready, ATTR_ID_Label, "Prepare")
		RGBColor (Ready, 255, 255, 0, 255, 0, 0)

		Attribute (ePrescription, ATTR_ID_Label, "ePrescription")
		RGBColor (ePrescription, 127, 0, 0, 255, 255, 0)


	}
	Else if @Mode ( ) = 0 and D1 <> "" and Cond1 <> "" then
	{
		Attribute (Ready, ATTR_ID_Label, "DONE")
		RGBColor (Ready, 255, 255,255, 0, 255, 0)

	}

 

« Last Edit: Jan 12th, 2016 at 1:19am by Bharat_Naik »  
Back to top
 
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Re-naming an element
Reply #2 - Jan 12th, 2016 at 4:00pm
Print Post Print Post  
I have the following programming:

// set DC: or COMP#:

if @left(Diacom P\N,2)= "AE" or @left(Diacom P\N,2)="CN"
{
     Attribute (DiaCom P\N, ATTR_ID_Label, "COMP#:")

}
else
{
     Attribute (DiaCom P\N, ATTR_ID_Label, "DC NO:")

}

I put this programming in the On Form Entry area but it doesn't work.

I've tested it with writeln statements and the logic of the IF statement is working and the programming is reaching the statement where I'm trying to change the label to "COMP#:" but the label doesn't change.

Interestingly, as I move to the next record using the F10 key, the label flashes "COMP#:" and then changes back to "DC NO:".

I've tried using the formcommit("") command before and after the IF statements with no success.

Any idea as to what is happening?
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Re-naming an element
Reply #3 - Jan 12th, 2016 at 6:01pm
Print Post Print Post  
I believe the problem is the Event, Form Entry, On form entry, I believe value of Diacom P\N is not placed yet.  Try using it in other event just for test, say on element exit on one of the element.
  
Back to top
 
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Re-naming an element
Reply #4 - Jan 12th, 2016 at 6:18pm
Print Post Print Post  
I tried putting it in another element's On Exit event.  It still did not change it.

Any other suggestions?
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Re-naming an element
Reply #5 - Jan 12th, 2016 at 6:57pm
Print Post Print Post  
Did you take the cursor and exit the element to see if it changes as per the conditional? Also wondering if Diacom P\N is the name of the element and not just label.  Is the element naming allows to use "\" in the element name?
  
Back to top
 
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Re-naming an element
Reply #6 - Jan 12th, 2016 at 8:20pm
Print Post Print Post  
I figured out what was wrong.  It was the designer!!

Many moons ago, I put a static text element over the label of the DiaCom P\N element to provide a way the users could easily see what was in the element in case the element info was larger than the space provided by the size of the element.

Anyway, this was hiding the element label i was changing.  So, my original programming is correct.

Thanks for your help.
  
Back to top
 
IP Logged