Hi!
I have a little issue that bothers me (my customers, actually) from time to time and I never found a good solution.
I´ve made subclasses of textboxes to act as an interface to particular tables in a database, for example the customers table so whe you enter the customer code or his/her name the textbox fires all needed methods to show all required data on a particular window. This worked perfectly until I added the feature to do "advanced searches" on that particular object by pressing a function key, let´s say search by preferred product brand if you press [F5]. The search is made and all occurrences -if there are more than 1- are shown on a list for the user to choose from. Then the proper Customer ID is put on the textbox and Valid event is fired. All this works perfectly, the search completes and the window is filled up with the required data. Then the problem appears, but randomly. After the special search returns control to KeyPress event an ASCII char corresponding to the function key is added at the beginning the textbox value so when the user leaves the textbox gets an error. I tried to force extra char deletion by issuing {HOME}+{DEL} but not always work.
Sample code:
** Code begins
** Code ends.
I know that I´m doing double search on the database here (adv search and Valid event) but I needed to add this feature over a working application, so the code had to be maintained compatible.
BTW, I´m using VFP8 w/sp1. Any help will be really appreciated.
Gerardo Czajkowski
I have a little issue that bothers me (my customers, actually) from time to time and I never found a good solution.
I´ve made subclasses of textboxes to act as an interface to particular tables in a database, for example the customers table so whe you enter the customer code or his/her name the textbox fires all needed methods to show all required data on a particular window. This worked perfectly until I added the feature to do "advanced searches" on that particular object by pressing a function key, let´s say search by preferred product brand if you press [F5]. The search is made and all occurrences -if there are more than 1- are shown on a list for the user to choose from. Then the proper Customer ID is put on the textbox and Valid event is fired. All this works perfectly, the search completes and the window is filled up with the required data. Then the problem appears, but randomly. After the special search returns control to KeyPress event an ASCII char corresponding to the function key is added at the beginning the textbox value so when the user leaves the textbox gets an error. I tried to force extra char deletion by issuing {HOME}+{DEL} but not always work.
Sample code:
** Code begins
Code:
txtCliente.Keypress:
LPARAMETERS nKeyCode, nShiftAltCtrl
LOCAL tF5 as Integer, tF6 as Integer, tComilla as Integer, tApostrofe as Integer
tF5 = -4
tComilla = 34
tApostrofe = 39
DO CASE
CASE INLIST(nkeycode, tComilla, tApostrofe)
KEYBOARD '{BACKSPACE}'
KEYBOARD '´'
CASE nKeyCode = tF5 AND this.tienebusqueda
THIS.busquedaavanzada
* KEYBOARD '{HOME}' && Tried with these here but doesn´t work, as sometimes
* KEYBOARD '{DEL}' && it erases the first customer ID digit.
ENDCASE
RETURN
txtCliente.BusquedaAvanzada:
LOCAL sValor as String, sQue_Busco as String, oTabla as Object
sValor = ""
DO FORM clientes_busqueda_avanzada TO sQue_Busco
IF LEN(ALLTRIM(sQue_Busco)) > 0
f_esp.dbf.motor.tabla_busquedaavanzada('vista_clientes', 'Nombre', sQue_Busco, "xTabla")
IF USED("xTabla")
IF RECCOUNT("xTabla") > 1
oTabla = CREATEOBJECT("tabla_clientes", "xTabla")
oTabla.Show
IF oTabla.Retval
sValor = xTabla.idCliente
ENDIF
oTabla.Release
ELSE
sValor = xTabla.idCliente
ENDIF
USE IN xTabla
IF VAL(sValor) <> VAL(this.Value)
THIS.Value = sValor
this.changed = .t.
this.Valid && Here customer ID is searched and data retrieved to be shown.
ENDIF
ENDIF
ELSE
this.changed = .F.
ENDIF
RETURN
I know that I´m doing double search on the database here (adv search and Valid event) but I needed to add this feature over a working application, so the code had to be maintained compatible.
BTW, I´m using VFP8 w/sp1. Any help will be really appreciated.
Gerardo Czajkowski
