Normal Topic XLookUp always comes back with 0 (Read 1212 times)
Darangen
Member
*
Offline



Posts: 8
Joined: Aug 25th, 2009
XLookUp always comes back with 0
Nov 5th, 2009 at 8:30pm
Print Post Print Post  
I'm having trouble with my @XLookUp programming.  Here is my code:

Code
Select All
var vSalary as Double

	vSalary = @toMoney(@XLookUp(@Fn, Employee Name, "EmployeeManagement!Employee", "Salary"))
	Salary0 = @STR(vSalary)

 



I'm wanting to look up the employee by their name, and find their current salary.  It's all on the same application, just different forms.

Employee Name is the element on the current form.
Employee is the element on the form I want to retrieve from (EmployeeManagement).
Salary is the data I want to retrieve.

Both elements are set to type MONEY, which is why I used a var Double.

For whatever reason, the value returned is always $0.00.

Any ideas?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLookUp always comes back with 0
Reply #1 - Nov 5th, 2009 at 8:39pm
Print Post Print Post  
You might try (untested):

Code
Select All
var vSalary as Money
var str as string

  str = @XLookUp(@Fn, Employee Name, "EmployeeManagement!Employee", "Salary")
  writeln(str)
  writeln(@Error)
  vSalary = @toMoney(str)
  writeln(vSalary)

 



I split the main line into two lines so I can see the result of the XLookup directly. Also, I used money type variable. See how that does for you.
  

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



Posts: 8
Joined: Aug 25th, 2009
Re: XLookUp always comes back with 0
Reply #2 - Nov 5th, 2009 at 8:45pm
Print Post Print Post  
Gave it a shot, the slate read:


no
0.0000


  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLookUp always comes back with 0
Reply #3 - Nov 5th, 2009 at 8:56pm
Print Post Print Post  
Code
Select All
var vSalary as Money
var str as string

  str = @XLookUp(@Fn, Employee Name, "EmployeeManagement!Employee", "Salary")
  writeln(@Error)
  writeln(str)
  vSalary = @toMoney(str)
  writeln(vSalary)

 



Try the code above. My Associate (Ray) correctly pointed out the first writeln resets the @Error we want to see from the @XLookup. You might also try putting square braces or some such around the strings in the writelns, so you can see if any are blank. You have two printed above and there are three writeln commands.
  

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



Posts: 8
Joined: Aug 25th, 2009
Re: XLookUp always comes back with 0
Reply #4 - Nov 5th, 2009 at 8:58pm
Print Post Print Post  
Basically changed the no to a yes, but did have a line of space between them:

yes

0.0000
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLookUp always comes back with 0
Reply #5 - Nov 5th, 2009 at 9:03pm
Print Post Print Post  
That "yes" means that there is a mistake in your @XLookup call itself. Triple check that all of your element names are correct. Make sure there is no security on the app. If there is make sure you have the X command password set correctly. You might want to writeln the result of @ErrorType and @ErrorString.
  

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



Posts: 8
Joined: Aug 25th, 2009
Re: XLookUp always comes back with 0
Reply #6 - Nov 5th, 2009 at 9:27pm
Print Post Print Post  
It's saying it's a Command Failure.

On the current form, the name of the element I want to write to is Salary0.
On the form I want to retrieve from, the name of the element is Salary.
The employee's name on the current form is in the element Employee Name.
On the form I want to retrieve from, the name is in... There's my problem.

Thanks Smiley  Turns out I must have changed the Employee to Employee Name on the other form.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLookUp always comes back with 0
Reply #7 - Nov 5th, 2009 at 9:29pm
Print Post Print Post  
Happy I could help.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged