Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check for dupe ID...
Message
 
 
À
25/01/2001 15:35:39
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00468745
Message ID:
00468828
Vues:
15
The same thing I, and others, told you about the ID being a primary key still applies when you change it to a Candidate Key. If you bind the text box control to the ID field, you will still get the uniqueness violated error if the user enters a dupe ID.

You do not need a memory variable just because a control is not bound to a field. I use local variables to store a control's value to because I do not like to use them in commands like SELECT - SQL, etc. IMO, this makes code more readable.

What I would do when the user clicks the NEW button to add a new record to the PERSON table is pop up a window [this could be a container on the form that is usually not visible. change the visible property to .T. when the ADD button is clicked] and ask the user to input an ID in a textbox that is not bound to any field. Include 2 buttons -- Cancel and OK. If the user clicks Cancel, then cancel the ADD. If they click OK, search the PERSON table for the value if the ID they entered in the textbox. If you get an EOF(), issue:
local lcTextBoxValue
lcTextBoxValue = alltrim(This.Parent.txtID.Value)
select PERSON
seel lcTextBoxValue
if eof()
   INSERT INTO PERSON ( ID ) values ( lcTextBoxValue )
   ThisForm.Refresh()
else
   ** ID already exists
endif
* if using a container, make the container Visible property False
>VFP 6.0
>
>In spite of my confusion, I am going back to square one! Now, I changed the PERSON table, ID field (person.id) index to Candidate key (named the index 'main'). On the form, upon clicking the 'Add' button, I have ALL fields remain disabled, but one, which is the person.id (so that I can program step by step). Yes, this is going to be for multi-users. I know this may be in somewhere in the books, but I want to ask here...
>
>Now, for the form, can I have the textbox (Text1) ControlSource as 'person.id' without using memory variable (like m.id) and be able to do checking on the real person table to check for duplicate ID? Would I use the '=TableUpdate' or save that '=TableUpdate' for the Save button (and '=TableRevert' for the Revert button)?
>
>If there is no dupe ID, should I save that record (append) automatically and then enable the rest of the fields for other data entry?
>
>If there is a dupe ID, how should I handle the error? Would other VFP error message pop up or it would be from my coding (since I am not using the Primary key anymore)? Would I be using the Valid Event?
>
>If the above is accordingly, then if the user did not want to save the record (hits the Revert button), would the '=TableRevert' be all I need?
>
>Lastly, as should, I also have a Delete button. I just delete the record (with a one last warning message), but not pack it. How should I handle this, with if the user types the same ID of a deleted record, should I simply pop up an error message with these words "You are about to recall a deleted record of a pervious person" and then if 'Yes', then recall that record and bring it up on the screen?
>
>If I can not use the 'person.id' for the Text1 ControlSource, then how would I 'refresh' the m.id in the text1 to show the correct ID from the table while the user navigates the records/grid?
>
>I may be asking for too much, but I would appreciate your help on this. I am trying to stop asking for help in the way I send the project (zipped) to you for you to look at it. If you feel insult or want to flame back, please don't reply then. Thank you.
>
>Chuck
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform