Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox in form problem

Status
Not open for further replies.

jhonny03

Programmer
Oct 28, 2015
23
PH
I have this textbox and combo box which is disabled.
when a command button is pressed the two controls are
enabled..but when after selecting my choice in the combo box,
the textbox is not clickable or it is like being disabled..
here is my code in the lost focus of my bombo box:
Code:
SELECT user_table 
LOCATE FOR utype="Administrator"
IF FOUND()
	IF utype="Administrator"
		MESSAGEBOX('Administrator cannot be duplicated!',16)
	ENDIF
ENDIF
 
I suspect the controlsource of the textbox is a field of the user_table. When Locate fails, you are at the EOF("user_table")
You can add an ELSE branch to IF FOUND(), to move somewhere else the record field in the user_table, like GO TOP

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
One observation:

If you LOCATE FOR utype="Adminstrator" and that location triggers FOUND() to be .T., then the record is found, so checking IF utype="Adminsitrator" is unneccessary. In a sense you are mistrusting the FOUND result.

There indeed is the chance to find something else, eg Administrator2, because of the nature of VFP string comparsons, but your double checking is also not making sure the trimmed value is literally "Administrator" in the literal sense of letter by letter, you'd need to LOCATE and check for ALLTRIM(utype)=="Administrator", unless SET EXACT is ON.

See this discussion about the fact of SET EXACT, SET ANSI string comparisons and == operator and a missing equivalent <> operator here: thread184-1757984

Bye, Olaf.

 
One more observation:

This code would fire up its message [tt]"Administrator cannot be duplicated!"[/tt] when only one record of the user_table has Administrator as utype field value, so you can't even have one Administrator, can you?
I don't know how this should work. If you want to prevent any duplicates you make a primary or candidate index on a field, that disallows such double records. The primary index should be done on the primary key only, though, but you can make as many candidate indexes as you like and need.

And yes, Mike is funny. I'd suggest making a beat box control and let it have several styles from bombo to snare drums, perhaps.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top