INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Search for Existing Record

Search for Existing Record

(OP)
I can't believe I'm having such a hard time getting this to work!  It's SO much easier in dBase/FoxPro!!  (ok, I feel better now)

I need to take what a user enters in a field (Company) and look it up to see if it already exists so I can stop them from entering duplicates (numerous ones already exist so I can't change the Key in the Dictionary).

I read somewhere that you have to create aliases in order to do key lookups, so I created one for the COMPANY file.  This is what I've been trying:


! Check for existing COMPANY
IF LocalRequest = InsertRecord
    ! Open secondary Company file
    OPEN(COMPANYALIAS)
    COMALIAS:Company = CO:Company
    ! Check if Company key exists
    GET(COMALIAS:CompanyKey,COMALIAS:Company)
    IF NOT EOF(COMPANYALIAS)
        MESSAGE('Company Found: ' & COMPANYALIAS:Company)
        CYCLE
    ELSE
        MESSAGE('Company NOT Found: ' & COMPANYALIAS:Company)
    END
END


Why isn't this working?  It keeps coming up "Company NOT Found" for existing and non-existing values and never hitting EOF on the alias.

RE: Search for Existing Record

I dont know if you are putting the correct keys but the typical way is this:

 in stead of
   GET(COMALIAS:CompanyKey,COMALIAS:Company)
   IF NOT EOF(COMPANYALIAS)
 
 put

    GET(COMPANYALIAS,COMALIAS:CompanyKey)
     IF NOT ERROR()

Hope this help

RE: Search for Existing Record

(OP)
IT WORKED!!  Thank you very much!!

RE: Search for Existing Record

Hi!

Even though IF ERROR() will work, IF ERRORCODE() is the more optimized way since ERRORCODE() is a integer number and ERROR() is a string.

Regards
 

RE: Search for Existing Record

(OP)
Interesting... okay, I'll try using that instead.  I'm just surprised EOF didn't work, but then I don't think I had GET correctly.  Thanks, ShankerJ!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close