Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Textbox with Control Source Problem ??
Message
 
À
27/01/2005 22:53:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows '98
Network:
SAMBA Server
Database:
Visual FoxPro
Divers
Thread ID:
00981597
Message ID:
00982542
Vues:
22
First, I'd like to point out that letting users enter a field that is your primary key is a very bad practice. A primary key should be a key that you generate automatically in your system, and the user doesn't usually even see it, let alone change it.

Now, here is a routine I use to check for duplicates in a field:
* Chk4Dup.prg		(c) 1999, Peisch Custom Software, Inc.

lparameters pNewVal, pFld, pCurRec

local lFnd, lOldRec, lOldAli

lFnd = .F.
lOldRec = recno()

lOldAli = alias()
select 0
use dbf(lOldAli) again alias DupChk

locate for eval(pFld) = pNewVal
if found()
   do while .T.
      if recno() = pCurRec
         continue
      else
         lFnd = .T.
         exit
      endif

      if eof()
         exit
      endif
   enddo
endif

if lFnd
   messagebox('Cannot enter duplicates in this field',48,'Duplicate found')
endif

use in DupChk
select (lOldAli)

return not lFnd
*-------------------------------------------------------
>HI All...........
>I Have table Customer with field id, name
>
>Field Id --> Primary Key
>
>*****
>Textbox1, controlsource=id
>Textbox2, controlsource=name
>
># When I Click in command button Add :
> Select 0
> append blank
>
># When I Save data with The same id An Error Occurs *** unique of index violation ***
> Select 0
> TableUpdate(.T.)
>
># I Want to Ask
>1. How to Check if a user typing with the same id, How to display existing data??? or How to Handle it
>2. How to manage Error Handler *** unique index violated ***
>
>Regards
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform