Normal Topic @XLookup Problem (Read 966 times)
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
@XLookup Problem
Dec 19th, 2007 at 5:56am
Print Post Print Post  
This may not be very concise programming, but I'm a newb.  Here's my basic problem, the following programming uses a certain number of the beginning characters of an entered address field to check for possible duplicates in its own form as well as another form in the same database.  If possible duplicates are found, a warning is posted in another element.

This warning system seems to work very well for my "Friends and Listeners" form, but in "Sticker Requests", where this programming resides, it flags almost every new form as a possible duplicate.  It also seems that the forms that are flagged are just flagged because the first two digits are similar.

Any ideas why this would be?

Code
Select All
 

if addressLength > 14
     then
     {
           alteredAddress = @Left(address0, 9) + ".."
     }
     else
     {
           if addressLength = 14 or addressLength = 13
           then
           {
                 alteredAddress = @Left(address0, 8) + ".."
           }
           else
           {      
                 if addressLength = 12 or addressLength = 11
                 then
                 {
                       alteredAddress = @Left(address0, 7) + ".."
                 }
                 else
                 {
                       if addressLength <= 10 and addressLength > 7
                       then
                       {
                             alteredAddress = @Left(address0, 6) + ".."
                       }
                       else
                       {
                             alteredAddress = address0
                       }
                 }
           }
     }
     If @Add then
     {
           dupAddress = @XLookup(@Filename, alteredAddress, "Friends and Listeners!address0", "address0")
           if dupAddress <> "" then
           {
                 if @Instr(Problems,"Possible duplicate address in Friends and Listeners") = 0 then
                 {
                       Problems = "Possible duplicate address in Friends and Listeners database;" + Problems
                 }
           }
           dupAddress = @XLookup(@Filename, alteredAddress, "Sticker Requests!address0", "address0")
           if dupAddress <> "" then
           {
                 if @Instr(Problems, "Possible duplicate address in Sticker Requests") = 0 then
                 {
                       Problems = "Possible duplicate address in Sticker Requests;" + Problems
                 }
           }
     }
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @XLookup Problem
Reply #1 - Dec 19th, 2007 at 2:02pm
Print Post Print Post  
Trying putting in a WriteLn for alteredAddress before the checks so you can see what you are comparing. Then put in a WriteLn for dupAddress after each of the @XLookups so you can see what is being found. This may give you a clue as to why you are getting a match when you don't think you should be.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Re: @XLookup Problem
Reply #2 - Dec 19th, 2007 at 7:00pm
Print Post Print Post  
OK thanks that helped me diagnose the problem...

I have entered this programming only in the Add Data Mode because I am importing all this information from an outside source and then running through it real fast to check for duplicates, etc.

What's happening is a flag will show up for a "duplicate" if I ever reenter the record, because the programming fires again and finds the exact same record that has already been entered (itself) and counts it as a duplicate.

I hope that isn't confusing, let me give a hypothetical scenario:

-I move through record 1, programming checks, no duplicates, move on to record 2.
-I move back to record 1 for some reason, programming checks record 2, no duplicates.
-When moving back from record 1 to record 2, programming checks, yes there is a duplicate (record 1 was already entered)
-Once I leave record 2 it will also be flagged as a duplicate because it also has already been entered.
-In this way, if I do any sort of normal activity between records when adding them, most records will be "duplicates"

Any ideas?
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @XLookup Problem
Reply #3 - Dec 19th, 2007 at 7:31pm
Print Post Print Post  
Take a look at @IsNew as opposed to @Add.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Re: @XLookup Problem
Reply #4 - Dec 19th, 2007 at 9:30pm
Print Post Print Post  
Thanks!  Good idea!
  
Back to top
 
IP Logged
 
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Re: @XLookup Problem
Reply #5 - Feb 20th, 2008 at 3:09am
Print Post Print Post  
Hi--

This program is no longer checking for duplicates as it was previously.  I am unable to look at the issue directly since I am away from the program, but I am trying to walk my parents through the issue.  The only thing that I can think is that they ran the latest Sesame update, and things may now be different.  Any ideas about what might have changed?

--Nate
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @XLookup Problem
Reply #6 - Feb 25th, 2008 at 2:32pm
Print Post Print Post  
Hello Nate,

I am not aware of any change in 2.0.5 that would affect this code. If your parents want they can send the DB and DAT files to support@lantica.com and we'll have a look at them and see what is happening.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged