Hot Topic (More than 10 Replies) Lookup (Read 1268 times)
Bejagee
Member
*
Offline


No personal text

Posts: 17
Joined: Dec 16th, 2003
Lookup
Apr 22nd, 2004 at 3:08pm
Print Post Print Post  
How do I lookup data from the same application but a different database?  I have3 databases in one app and would like to pull data from the Customer database to the Parts database.
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Lookup
Reply #1 - Apr 22nd, 2004 at 4:00pm
Print Post Print Post  
Check out the programming guide starting on page 124

In my example below I am looking up data from another database in the same application. I am checking to see if the elements that the retrieved data will be placed is empty if it is I transfer the data if not I check with the user first.  The part you are interested in is the Xlookup. The @fn refers to the actual application you are in use this instead of typing the complete path and file name.

I hope this starts you in the correct direction.

var vAddevinspri as string

vAddevinspri = EVInscoNamePrimary + EVInscoStreetPrimary +EVInscoCityPrimary
     + EVInscoStatePrimary + EVInscozipPrimary + EVInscophonePrimary +
     EVInscoKeyPrimary + EVInscogrpPrimary + EVInscoplanPrimary




if vAddevinspri <> "" then
{
if @AskUser("There is existing data in the Primary Ins ", "do you want to replace","existing Insurance data with Default Insurance") 
{
     
     Xlookup(@fn, patientid, "patientid", "InscoNamePrimary", EVInscoNamePrimary)
     Xlookup(@fn, patientid, "patientid", "InscoStreetPrimary", EVInscoStreetPrimary)
     Xlookup(@fn, patientid, "patientid", "InscoCityPrimary", EVInscoCityPrimary)
     Xlookup(@fn, patientid, "patientid", "InscoStatePrimary", EVInscoStatePrimary)
     Xlookup(@fn, patientid, "patientid", "InscozipPrimary", EVInscozipPrimary)
     Xlookup(@fn, patientid, "patientid", "InscophonePrimary", EVInscophonePrimary)
     Xlookup(@fn, patientid, "patientid", "InscoKeyPrimary", EVInscoKeyPrimary)
     Xlookup(@fn, patientid, "patientid", "InscogrpPrimary", EVInscogrpPrimary)
     Xlookup(@fn, patientid, "patientid", "InscoplanPrimary", EVInscoplanPrimary)

}
}
else
{
     Xlookup(@fn, patientid, "patientid", "InscoNamePrimary", EVInscoNamePrimary)
     Xlookup(@fn, patientid, "patientid", "InscoStreetPrimary", EVInscoStreetPrimary)
     Xlookup(@fn, patientid, "patientid", "InscoCityPrimary", EVInscoCityPrimary)
     Xlookup(@fn, patientid, "patientid", "InscoStatePrimary", EVInscoStatePrimary)
     Xlookup(@fn, patientid, "patientid", "InscozipPrimary", EVInscozipPrimary)
     Xlookup(@fn, patientid, "patientid", "InscophonePrimary", EVInscophonePrimary)
     Xlookup(@fn, patientid, "patientid", "InscoKeyPrimary", EVInscoKeyPrimary)
     Xlookup(@fn, patientid, "patientid", "InscogrpPrimary", EVInscogrpPrimary)
     Xlookup(@fn, patientid, "patientid", "InscoplanPrimary", EVInscoplanPrimary)


}
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bejagee
Member
*
Offline


No personal text

Posts: 17
Joined: Dec 16th, 2003
Re: Lookup
Reply #2 - Apr 23rd, 2004 at 3:28pm
Print Post Print Post  
That did the trick.  Thanks!

Next question:  How do I copy certain data fields from one application to a different one?
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Lookup
Reply #3 - Apr 23rd, 2004 at 4:34pm
Print Post Print Post  
Quote:
How do I copy certain data fields from one application to a different one?


There might be a cleaner way but I use the same xlookup command and use the complete path and database name. This example checks for 5 digits when exiting zipcode element and if 5 digits are present it uses the sample zip code database to return the city, state and time zone to the other app. This is not the best written validation routine example but it works as a learning tool.

// checks for at least 5 digits in zip code

If @len(@num(homezip)) < 5 then
     {@Msgbox("The ZipCode Must be" , "at least five digits." , "Please correct the entry.")

     Goto homezip
}

// see page 44 in prog guide if need to add else goto statement


      Xlookup("C:\Sesame\Data\Samples\ZipCode.db", homezip, "zip code", "city", Homecity)
      Xlookup("C:\Sesame\Data\Samples\ZipCode.db", homezip, "zip code", "state", Homestate)
      Xlookup("C:\Sesame\Data\Samples\ZipCode.db", homezip, "zip code",  "Full county", HomeCounty)
      Xlookup("C:\Sesame\Data\Samples\ZipCode.db", homezip, "zip code",  "Time Zone", HomeTZ)
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bejagee
Member
*
Offline


No personal text

Posts: 17
Joined: Dec 16th, 2003
Re: Lookup
Reply #4 - Apr 26th, 2004 at 12:59pm
Print Post Print Post  
I should clarify.

I'm looking to copy data from one database to another in much the same way that Q&A does it.  I need to copy certain static data from the Parts database to the Order database when we create new orders.

  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Lookup
Reply #5 - Apr 26th, 2004 at 1:22pm
Print Post Print Post  
Can you please describe in more detail what you are trying to do?

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bejagee
Member
*
Offline


No personal text

Posts: 17
Joined: Dec 16th, 2003
Re: Lookup
Reply #6 - Apr 26th, 2004 at 2:10pm
Print Post Print Post  
What we do now (in Q&A) is copy data from the Part database (customer, part number, notes, etc...) into the Order file, and then go into the Order file and update those records with order numbers, dates, etc.

Now that I've translated those files to Sesame, each database is in a separate application and I'm not sure how to copy data from one to the other.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Lookup
Reply #7 - Apr 26th, 2004 at 3:44pm
Print Post Print Post  
Quote:
What we do now (in Q&A) is copy data from the Part database (customer, part number, notes, etc...) into the Order file, and then go into the Order file and update those records with order numbers, dates, etc.


I have also faced the similar problem. In Sesame, to accomodate this, you have to have a database with two forms (In one single application).
Customer
orders

Whatever elements that you are copying now in Q&A from one database to another, make it a common elements in both forms.... bound these elements to the respective common fields.  This way when you are entering a customer in customer form, you are also entering customer# in the order form.  This way you do not have to copy anything.  Am I clear?
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Lookup
Reply #8 - Apr 26th, 2004 at 4:19pm
Print Post Print Post  
Bharat,

Sometimes I am just dense. Angry I am not following what exactly the problem is that Bejagee  is  attempting to overcome. You seem to understand, could you spell it out for me.

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Lookup
Reply #9 - Apr 26th, 2004 at 4:49pm
Print Post Print Post  
Bob,
He has two databases in Q&A. When he translated in Sesame, that made two separate applications. In Sesame,  one can copy value from on form to another if they the forms belong to the same application. Here he has two separate applications.  How can he copy in sesame, the same way he could do in Q&A from one database to another database? (Copy can would not work with two separate applications in Sesame.)

In Q&A, one can have multiples databases that will add record and update records using copy, mass update with programming in On record exit and On record entry form along with macors and one would not have to enter data or open that database manually.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Lookup
Reply #10 - Apr 26th, 2004 at 5:04pm
Print Post Print Post  
---Continue from previous posting---

In Sesame, we can have mutiple forms in a database and one can bind the elements of the different forms to the same field of the database that will eliminate need of copying.  One can use Mass Update and realtime posting in Sesame to keep the other form (and hence the other fields of database) upto date.  

One would think that how about using xlookup? In order to use xlookup or posting, you got to have key fields in the form that in Q&A we got it using copy and in Sesame one can have binding the element of the form that is also bound to some other form and it has gotten its data through other form entry.  Am I clear?
  
Back to top
 
IP Logged