Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ENTER (if you dare!!!)
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01161171
Message ID:
01161232
Views:
14
>IF THISFORM.m_DataKeyPress(nKeyCode,.F.)
>
>You need to return something from the m_DataKeyPress to the Keypress methos so that it knows that the keystroke has been handled and can then issue the NODEFAULT.

Ok... here is the new code.......

I added a new property to the form... Thisform.p_EnterKey set to .F.

For the txtGridFilter keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
LOCAL lcFilter, lcSetExact

lcSetExact = SET('EXACT')

IF THISFORM.m_DataKeyPress(nKeyCode,.F.)
	SET EXACT OFF

	IF THISFORM.p_viewtype = 1
		SELECT refill
		SET FILTER TO INLIST(STATUS,0,1,4,5)	&& 4 Included so batch Rx's cant be refilled

		SET EXACT OFF
		lcFilter = IIF(NOT EMPTY(THISFORM.p_buffer),;
			THISFORM.p_previousdrugfilter + " AND UPPER(drug.name) = '" + ;
			ALLTRIM(UPPER(THISFORM.p_buffer)) + "' IN Rx",;
			THISFORM.p_previousdrugfilter + " IN Rx")
		SET FILTER TO &lcFilter
		GO TOP IN rx
	ELSE
		SELECT refill
		SET FILTER TO
		SELECT rx

		SET EXACT OFF
		lcFilter = IIF(NOT EMPTY(THISFORM.p_buffer),;
			"UPPER(drug.name) = '" + ;
			ALLTRIM(UPPER(THISFORM.p_buffer)) + "' IN Rx","")
		SET FILTER TO &lcFilter
		GO TOP IN rx
	ENDIF
	THISFORM.grdProfile.REFRESH()

	SET EXACT &lcSetExact
	IF Thisform.p_Enterkey = .T.
		NODEFAULT
		Thisform.grdProfile.SetFocus
	ENDIF
ENDIF
And the code for the frmProfile.m_datakeypress method....
LPARAMETERS nKeyCode, llSearchNumbersOnly
LOCAL llRecJump

llRecJump = .F.
Thisform.p_Enterkey = .F.

DO CASE
CASE nKeyCode = 3							&& Ctrl + C
	THISFORM.p_Buffer = ""
	THISFORM.cntActions.txtDrugFilter.VALUE = ""
CASE nKeyCode = 13							&& Enter
	Thisform.p_Enterkey = .T.
CASE nKeyCode = 32							&& Space
	THISFORM.p_Buffer = THISFORM.p_Buffer + " "
	llRecJump = .T.
CASE (nKeyCode = 7) OR (nKeyCode = 127)		&& Backspace or Del
	IF LEN(THISFORM.p_Buffer) > 0
		THISFORM.p_Buffer = LEFT(THISFORM.p_Buffer,(LEN(THISFORM.p_Buffer) - 1))
		llRecJump = .T.
	ENDIF
CASE BETWEEN(nKeyCode,33,126)				&& Printable chars
	IF BETWEEN(nKeyCode,48,57)				&& 0 - 9
		THISFORM.p_Buffer = THISFORM.p_Buffer + CHR(nKeyCode)
		llRecJump = .T.
	ELSE
		IF !llSearchNumbersOnly
			THISFORM.p_Buffer = THISFORM.p_Buffer + CHR(nKeyCode)
			llRecJump = .T.
		ENDIF
	ENDIF
ENDCASE

RETURN llRecJump
Only catch is... when you press ENTER, it jumps to the next object which is a combobox, not the grid... sigh......

Thanks!
Tommy Tillman A+ NetWork+ MCP
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform