Normal Topic internal lookups - possible? (Read 1527 times)
beagle
Junior Member
**
Offline


No personal text

Posts: 80
Location: australia
Joined: May 28th, 2004
internal lookups - possible?
Sep 4th, 2004 at 5:24am
Print Post Print Post  
Hi,

Is it possible to program "internal lookups" in sesame ?.

What I would like to do is set up a picklist of "names" already entered into a database, rather than performing an xuserselectr into a second database.

any advice warmly welcomed Smiley

beagle
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: internal lookups - possible?
Reply #1 - Sep 4th, 2004 at 3:38pm
Print Post Print Post  
You can do an XLOOKUP into the same database rather than having a separate database.  For example suppose you have a NAMES database with normal name, address, phone number info.  No need for a separate ZipCode database.

You can do
City=@XLU(@FN,ZipCode,"frmName!ZipCode","City") to fill in the City automatically from the Zip code value.  Do the same thing for the State and Area Code.  If the Zip Code does not exist, then you can ThrowFocus to the City code and fill it in.  Then save the record.  the next name you enter that zipcode, the City will then be filled in automatically for all subsequent entries.

Could look something like this untested code.

Quote:
//Prevent overwrite of existing values
If NOT @ISBLANK(City) Then {
ReadOnly(City,1)
ReadOnly(State,1)
ReadOnly(ZipCode,1)  }

If @ISBLANK(City) Then {
City=@XLU(@FN,ZipCode,"frmName!ZipCode","City"
If @Error Then {
@MsgBox("This Zip Code was not found.","Please enter information manually","")
ThowFocus(City) }

Else  {
State=@XLU(@FN,ZipCode,"frmName!ZipCode","State")
ZipCode=@XLU(@FN,ZipCode,"frmName!ZipCode","AreaCode")
ReadOnly(City,1)
ReadOnly(State,1)
ReadOnly(ZipCode,1)
ThrowFocus(Phone) }
}


This will result in a self building internal ZipCode database that only contains the zipcodes you actually use.  Of course  if you have more than one record with the same zipcode value, you need to make sure that no one changes any of the values in the fields you lookup, since the key record that is looked at will be a random selection of the multiple records with that zipcode.  That is the purpose of the ReadOnly code in this sample.

The initial ReadOnly code could go into the OpenForm event. 
The rest of the code could go into Exit Field event for ZipCode. 
Could use ThrowFocus to move to the ZipCode field before going to the City/State/AreaCode fields, overriding the normal top to bottom, left to right tab flow.

Just trying to provide a possible example of how to do an "internal" lookup vs. creating another database.

====================
Original sample has been subsequently edited from SetFocus to ThrowFocus thanks to Erika's catch. Embarrassed
Additional change found by beagle:  Added @ to ISBLANK to make @ISBLANK (told you it was untested).
« Last Edit: Sep 5th, 2004 at 2:06pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: internal lookups - possible?
Reply #2 - Sep 4th, 2004 at 3:49pm
Print Post Print Post  
You can always spot people who work in more than one programming language in any given week.  Wink

In Sesame, it's ThrowFocus().  SetFocus is the various Visuals and .NETs.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: internal lookups - possible?
Reply #3 - Sep 4th, 2004 at 6:15pm
Print Post Print Post  
Embarrassed  EmbarrassedArrgh!.  Got me!  I told you it was untested!.  Embarrassed Embarrassed

I have corrected the original untested sample above......thanks.
« Last Edit: Sep 5th, 2004 at 2:08pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
beagle
Junior Member
**
Offline


No personal text

Posts: 80
Location: australia
Joined: May 28th, 2004
Re: internal lookups - possible?
Reply #4 - Sep 4th, 2004 at 11:22pm
Print Post Print Post  
Thanks so much guy's (& gals)

Not only a fast reply, but quality controlled as well  Wink

I was having real trouble getting my head around this "challenge" & did'nt even think of the "not blank" senario.

Your help is very much appreciated

Beagle
  
Back to top
 
IP Logged
 
beagle
Junior Member
**
Offline


No personal text

Posts: 80
Location: australia
Joined: May 28th, 2004
Re: internal lookups - possible?
Reply #5 - Sep 5th, 2004 at 6:22am
Print Post Print Post  
Hi,

just an update,
Thanks to your guide I am now able to what I wanted to do with the "xuserselectr" command (& I found a use for the "xlookup" (as described) command as well), two birds with one stone - thanks very much, I really do appreciate your help.

for the benefit of any other non programmers out there
there was another tiny error in the programming the "ISBLANK" command needs a @ in front of it.
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: internal lookups - possible?
Reply #6 - Sep 5th, 2004 at 2:07pm
Print Post Print Post  
Thanks for the note about @ISBLANK, beagle.  I have modified the original untested sample.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged