Normal Topic Xlookup - Same Application (Read 758 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Xlookup - Same Application
Nov 22nd, 2005 at 5:26am
Print Post Print Post  
Hi -

I've been at this too long and would appreciate programming help to do an x-lookup to a second database within the same application.

Here's what I've been working with:

[code]XLOOKUP("C:\Sesame\data\groceries.db", Category,"Publix Grocery!newdatabase0!category!category", "aisle", aisle)
if @error then @msgbox("Lookup Failed - Sorry!","","")[/code]

and numerous variations thereof, always in  Category::On Element Exit

The name of my file is:  C:\Sesame\Data\groceries.db

The name of my Application is:  Publix Grocery

The name of my primary database (for now) is: NewDatabase

The name of my primary form (for now) is: NewForm

The name of the element I am looking up from is:  Category

The name of my lookup database (for now) is:NewDatabase0

The name of my lookup form is:  Category

The name of my lookup field is:  Category

And, the name of my "value" field is Aisle.

I simply want to look up the category and have it retrieve and return the aisle number.

If I see my own error message one more time, I am going to scream ... so pleeease help.  lol

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Xlookup - Same Application
Reply #1 - Nov 22nd, 2005 at 1:01pm
Print Post Print Post  
First and foremost (and this is very important!) rename either your LE or your form. As has been mentioned in another thread here, allowing them both to have the same name is a 1.1.2 bug. It has been remedied in 1.1.3. Do this before you do anything else.

Try this (change the names as needed):
Code
Select All
var str as string
str = @XLookup(@fn, CategoryLE, "CategoryForm!CategoryLE", "aisle")
if(@Error)
{
  @MsgBox("Lookup Failed - Sorry!", "", "")
}
else
{
  aisle = str
}
 

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Xlookup - Same Application
Reply #2 - Nov 22nd, 2005 at 3:57pm
Print Post Print Post  

Lookup Failed - Sorry!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
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 - Same Application
Reply #3 - Nov 22nd, 2005 at 4:01pm
Print Post Print Post  
Hello Spencer,

You're not in preview mode are you?
Did you rename the element and change the code to match the new element name in both places?

Does
Code
Select All
WriteLN(@XListValues(@fn, "CategoryForm!CategoryLE")) 

return any values?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Xlookup - Same Application
Reply #4 - Nov 22nd, 2005 at 4:47pm
Print Post Print Post  
Hi -

Oops!  I cannot tell a lie.  As many times as I've read and heard it, I forgot that Xlookups do not work in Preview mode (yet) lol  OK, back to being serious.

First thing I did was change the name of the newdatabase0 form to Categories.  Also, now that I'm more involved in this, I will start practicing good naming conventions which Bob Hansen has been preaching to me since day one.  I always hated Access' naming convention like frmthis or rptthat, that I just wanted a reprieve for a while.  I'll be good from now on.  (And, I'm surprised that Mark beat Bob in pointing this out.  I thought Bob was the first one I would hear from about my sloppy, sloppy work - lol)

I'll also stop using old Q&A style programming - as much as I can - and start using variables more.  

Now, Mark's programming got me closer but I am still having problems.

Your writeln suggestion (as Mark has pointed out in the past) was definitely helpful.  

What this showed me is that SOME lookups did work and what was returned by writeln was the entire string of values in my Category::On Element Entry code.

[code]var vList as String

vList = "Air Fresheners;etc;etc;Coolers;Wines;Yeast"

PopulateListElement(Category;vList)[/code]

These values were exported from my "lookup" database so I expected there not to be any typos or inconsistencies between the values entered in the database and the values entered in code.

Yet, I am finding inconsistencies such as applesauce in the lookup database and apple sauce in my code.  I don't understand HOW that happened but at least it explains WHY some lookups are failing.  I'll see what I can do to straighten that out and get this thing settled once and for all.

Thanks very much to both of you for all your (continued) help.



  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged