Normal Topic Fill one element, deny access to another? (Read 991 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Fill one element, deny access to another?
Nov 7th, 2006 at 5:12pm
Print Post Print Post  
I have 2 money elements, either of which can contain an amount that will be added into a "total" element elsewhere on the form.  However, I want to program the form so that only one of the elements can contain a value.  That is, if Element1 has an amount in it, entry into Element2 is disallowed, and vice versa.  It might also be nice to have a "you can't do that" message pop up if the user gives it a try.  The user would then have to delete the value in the first element, thereby freeing up entry into the other.

In general terms, what would be the best way to go about this?
  

**
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: Fill one element, deny access to another?
Reply #1 - Nov 7th, 2006 at 6:25pm
Print Post Print Post  
Just a quick reactive thought, untested ........

Use same type of programming in both elements
=====================================

On Enter Element program
Save current value as global variable

On Exit element program
If other element has a value send message confirming use this vs that
If confirmed, clear other value and finish

If not confirmed restore initial value using global variable
--------------------------------------------------------------------------

Might also want to consider a message On Element Entry
If other element has value, message asking to confirm entry here to replace the other one.
React based on confirmation.

Might also want to consider changing element Visibility and ReadOnly states based on conditions.  Need more information about how you are using these elements.  If both are empty then both are wide open.  If one is not empty then the other one is locked out.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
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: Fill one element, deny access to another?
Reply #2 - Nov 7th, 2006 at 7:13pm
Print Post Print Post  
Bob_Hansen wrote on Nov 7th, 2006 at 6:25pm:
Just a quick reactive thought, untested ........

Use same type of programming in both elements
=====================================

On Enter Element program
Save current value as global variable

On Exit element program
If other element has a value send message confirming use this vs that
If confirmed, clear other value and finish

If not confirmed restore initial value using global variable
--------------------------------------------------------------------------

I think I see what you're saying (I'm still relatively new to global variables and their uses) but I'm not sure that's the way I want to go.  The value doesn't really matter.

Quote:
Might also want to consider a message On Element Entry
If other element has value, message asking to confirm entry here to replace the other one.
React based on confirmation.

Yes, this sounds like part of my solution.

Quote:
Might also want to consider changing element Visibility and ReadOnly states based on conditions.  Need more information about how you are using these elements.  If both are empty then both are wide open.  If one is not empty then the other one is locked out.

I'd like both to remain visible, but maybe Read Only is the way to go.  Yes, if both are empty then either one can be filled.  However, as soon is one is filled, the other is locked out.  If the user then deletes the value in the one, both become wide open again.

I'll read up on programming Read Only.  Is it possible for a message to pop up if a user tries to enter a Read Only field?

Thanks Bob.
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Fill one element, deny access to another?
Reply #3 - Nov 8th, 2006 at 2:23am
Print Post Print Post  
Captain,

You could also try this:
Code
Select All
// Place this in the "A :: On Element Immediate Change" event
If NOT @IsBlank(B)
	{
	@MsgBox("You cannot have a value in both the A and B elements",
		"",
		"If you want a value in this element, first delete the other one.")
	Clear(ThisElement)
	}

// Place this in the "B :: On Element Immediate Change" event
If NOT @IsBlank(A)
	{
	@MsgBox("You cannot have a value in both the A and B elements",
		"",
		"If you want a value in this element, first delete the other one.")
	Clear(ThisElement)
	}
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Fill one element, deny access to another?
Reply #4 - Nov 8th, 2006 at 3:00pm
Print Post Print Post  
Thanks Carl, that looks very clean and might be just what I need.  I'll give it a try!
  

**
Captain Infinity
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: Fill one element, deny access to another?
Reply #5 - Nov 8th, 2006 at 5:03pm
Print Post Print Post  
Carl, that's working well, thanks again.  Now I need to check against the total, and for this I think I need to go to Bob's idea of setting a Global Variable.  I'm having some trouble figuring out how to do this.  I'm hitting the books as I type this, but any hand-holding anyone can provide would be appreciated.

Here's what I'm trying to do.... A picture of my form can be seen at http://www.jamiara.com/invform.jpg  As you can see, the Vehicles and Labor sections have two columns to the right of the description lines.  The column on the left, in yellow, total up into the Totals line (under the gray elements).  If any yellow element has an entry, the gray element to the right is disallowed, and vice versa.  That's working, thanks again Carl.

The Total element (under the gray) should be manually editable UNLESS any of the yellow elements above have an amount, in which case editing is disallowed because it works as an automatic total of all the yellows. 

So I need to set the Global Variable equal to the value of the yellow total element.  If any of the left-column yellows have an entry, its value will be <>0.  If that's the case and a user tries to edit it I need to pop up a message box saying "no way" and reset the value back to the global variable.  If none of the left-column yellows have a value, then the total box can be edited any way the user pleases.

Conceptually, I think I've got it straight, and even as far as which on-element action I think I'm clear.  But the specifics of setting a global variable and then checking against it are not in my toolbox yet.

Thanks in advance for any help.
  

**
Captain Infinity
Back to top
IP Logged