Key Violations 
Author Message
 Key Violations

Quote:
> Is there any way to allow a form to recognize a key violation BEFORE
> you spend your day filling out the form?  We have a form that has a
> number of fields that are to be filled out, some of which require
> looking things up, etc.  The key is a single Alpha field.

In the canDepart method of the key field use a tCursor (already opened
in the form open method) to perform a qLocate() and not allow the user
to leave the field if a violation is detected. The tCursor should not be
in edit() mode.

Daniel A. Morgan



Sun, 24 Oct 1999 03:00:00 GMT
 Key Violations

Capture the single alpha string in a simple dialog, check it against
the table and provide an error msg if its redundant; otherwise, ins a
new record, write in the filed and let them complete the rest of the
form.


Quote:
>Is there any way to allow a form to recognize a key violation BEFORE you
>spend your day filling out the form?  We have a form that has a number
>of fields that are to be filled out, some of which require looking
>things up, etc.  The key is a single Alpha field.  I found a way in a
>book to work around a key violation by saving the record elsewhere,
>etc., but the person who is filling in the form is not very computer
>literate and I need to keep things simple.  Any Ideas?



Sun, 24 Oct 1999 03:00:00 GMT
 Key Violations

Quote:

> In the canDepart method of the key field use a tCursor (already opened
> in the form open method) to perform a qLocate() and not allow the user
> to leave the field if a violation is detected. The tCursor should not be
> in edit() mode.

What if your key is made up of more than one field.
Quote:

> Daniel A. Morgan



Mon, 25 Oct 1999 03:00:00 GMT
 Key Violations

Why not just place the following in the forms error method:

;// This code executes only for the form:
                if errorcode()=9729 then
                  msgstop("Key violation","Record Already Exists")
                  Patient_ID=""
                  Moveto(Patient_ID)
                endif

Quote:


> > In the canDepart method of the key field use a tCursor (already opened
> > in the form open method) to perform a qLocate() and not allow the user
> > to leave the field if a violation is detected. The tCursor should not be
> > in edit() mode.

> What if your key is made up of more than one field.

> > Daniel A. Morgan



Tue, 26 Oct 1999 03:00:00 GMT
 Key Violations

Quote:

>Why not just place the following in the forms error method:

>;// This code executes only for the form:
>            if errorcode()=9729 then
>                  msgstop("Key violation","Record Already Exists")
>              Patient_ID=""
>              Moveto(Patient_ID)
>                endif



A user could waste a lot of time filling out the form before they
attempt to move away and THEN discover that its redundant...better to
check before with the opportunity to provide an explanatory error -
perhaps redundant records should be trapped into a separate db for
instance...
Quote:


>> > In the canDepart method of the key field use a tCursor (already opened
>> > in the form open method) to perform a qLocate() and not allow the user
>> > to leave the field if a violation is detected. The tCursor should not be
>> > in edit() mode.

>> What if your key is made up of more than one field.

>> > Daniel A. Morgan



Tue, 26 Oct 1999 03:00:00 GMT
 Key Violations

Here's some code I use to move to the record if it's already in the
table.  The code is attached to the changeValue method of the key field
on the form:

;;this method finds the student, if they've already been entered,
;;otherwise it accepts the new student.
<*snip*>
method changeValue(var eventInfo ValueEvent)
var
        tc      tcursor
endvar
if tc.open(":yourAliasHere:tableWhereKeyIs.db") then
        if tc.qlocate(eventInfo.newValue()) then        ;looks for value in table
                                                        ;...and leaves tc pointing
                                                        ;...to found value (same)
                self.action(dataCancelRecord)           ;cancels record
                self.resync(tc)                         ;resynchronizes table to object
        else
                self.action(dataPostRecord)             ;posting the record allows
                                                        ;...changeValue (this method) to
                                                        ;...accept the change.
        endif
tc.close()
endif

endMethod
<*snip*>

Quote:

> Capture the single alpha string in a simple dialog, check it against
> the table and provide an error msg if its redundant; otherwise, ins a
> new record, write in the filed and let them complete the rest of the
> form.


> >Is there any way to allow a form to recognize a key violation BEFORE you
> >spend your day filling out the form?  We have a form that has a number
> >of fields that are to be filled out, some of which require looking
> >things up, etc.  The key is a single Alpha field.  I found a way in a
> >book to work around a key violation by saving the record elsewhere,
> >etc., but the person who is filling in the form is not very computer
> >literate and I need to keep things simple.  Any Ideas?

--

http://students.cs.byu.edu/~wiersdor
"For every complex problem, there is
a solution that is simple, neat, and
wrong." -- H. L. Mencken


Mon, 01 Nov 1999 03:00:00 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. INSERT INTO TABLE KEYED ONLY ON IDENTITY COLUMN RESULTS IN KEY VIOLATION (6.5)

2. Paradox Key Violation - changing a keyed field

3. Preventing Key Violation for duplicate keys

4. Reordering of key fields leads to key violations (Pdox 5.0)

5. Reordering of key fields leads to key violations (Pdox 5.0)

6. Access Key Violation in Index aaaaaPk....

7. FoxPro->SQLServer key violation

8. Missing key violation

9. ERROR: ODBC/SQLServer Primary key violations

10. IDENTITY (MSSQL 6.5) - Primary Key violation

11. Help Primary Key violation

12. Proc with MTS causes EM to lock up when Foriegn key violation


 
Powered by phpBB® Forum Software