Normal Topic "X" Family Question (Read 1279 times)
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
"X" Family Question
Dec 22nd, 2006 at 1:01am
Print Post Print Post  
Another question (are you tired of me yet?)

I have successfully implemented the following code in order to check the address field to make sure it isn't a duplicate of a record that has already been entered (only one form in my database):

var DupAddress as string
DupAddress = @XLookup(@Filename, address0, "address0", "address0")
if DupAddress <> "" then
@Msgbox("Panic!","You may have already entered this address!","Look it up now to double check...")

I am now looking to develop this code a little to deal with possible discrepencies with the endings of addresses, ie, if the user enters "123 Forest Ave." she will be notified of the existence of "123 Forest Avenue", etc.

If I were to take a certain number of the first characters of the address, could I use @XLookup or a similar command from the "X" family to do something to the equivalent of the search function "123 Fore.."?  Which command should I start with?  How much would this lag the system?

Thanks so much...
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: "X" Family Question
Reply #1 - Dec 22nd, 2006 at 1:15am
Print Post Print Post  
The key value in any of the "X" command takes a search spec. So to find all the address that start with "m" you can use "m..". So to find both "123 Forest Ave" and "123 Forest Avenue", you could use "123 Forest Av..".
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Re: "X" Family Question
Reply #2 - Dec 22nd, 2006 at 1:33am
Print Post Print Post  
What am I doing wrong?:

(variables declared)

alteredAddress = @Left(address0, 10)

dupAddress = @XLookup(@Filename, "alteredAddress..", "address0", "address0")
if dupAddress <> "" then
@Msgbox("Panic!","You may have already entered this address!","Look it up now to double check...")
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: "X" Family Question
Reply #3 - Dec 22nd, 2006 at 1:41am
Print Post Print Post  
nateboone wrote on Dec 22nd, 2006 at 1:33am:
What am I doing wrong?:

(variables declared)

alteredAddress = @Left(address0, 10)

dupAddress = @XLookup(@Filename, "alteredAddress..", "address0", "address0")
if dupAddress <> "" then
@Msgbox("Panic!","You may have already entered this address!","Look it up now to double check...")


You are putting the variable in double quotes, that makes it a literal string instead of getting the value in the variable. Try this:
Code
Select All
alteredAddress = @Left(address0, 10) + ".."

dupAddress = @XLookup(@Filename, alteredAddress, "address0", "address0")
if(dupAddress <> "")
{
    @Msgbox("Panic!", "You may have already entered this address!", "Look it up now to double check...")
}
 



BTW: Never tell a computer user to panic unless the user or computer are on fire.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Re: "X" Family Question
Reply #4 - Dec 22nd, 2006 at 8:20pm
Print Post Print Post  
Thanks, works great!

Another question: is there a way to look up and match more than one field at a time using XLookup?  The application of this would be if an address starts with "P.O. Box", I would want to warn the user only if there is a matching address and Zip code, because otherwise matching P.O. Boxes are too common and not worth the user's time.

If I was to try to do something like this:

dupAddress = @XLookup(@Filename, address0, "address0", "address0")
dupCity = @XLookup(@Filename, Zip0, "Zip0", "Zip0")
if dupAddress <> "" and dupCity <> ""
then...

XLookup would look up matching fields but not neccessarily in the same form.  Can I get them to sync and find if there are any matching fields on the same form?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: "X" Family Question
Reply #5 - Dec 22nd, 2006 at 8:39pm
Print Post Print Post  
You can use @XLookupSourceListAll to find all the records that have the same PO Box string and then run through the results to see if they have the same zip code.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Re: "X" Family Question
Reply #6 - Dec 22nd, 2006 at 9:22pm
Print Post Print Post  
Thanks for the idea it turned out great!   Smiley
  
Back to top
 
IP Logged