Normal Topic Using @XLookupR instead of @Number (Read 699 times)
nateboone
Junior Member
**
Offline



Posts: 54
Joined: Dec 19th, 2006
Using @XLookupR instead of @Number
Dec 19th, 2006 at 4:59am
Print Post Print Post  
I am trying to use @XLookupR to search the current database for the highest Receipt Number (ie last one assigned), in order to avoid the inflexibility of @Number.  This programming simply returns "00001" in my Receipt Number field:

var nextNumInt as int
var nextNumStr as string

nextNumInt = @ToNumber(@XLookupR(@FN, "99999", "Receipt Number0", "Receipt Number0")) + 1

nextNumStr = @right("00000" + @str(nextNumInt), 5)

Receipt Number0 = nextNumStr

I suspect I might be getting confused with mixing up @ToNumber and @Str types?  What else might I be missing?  Thanks for any help out there for a newbie like me...
  
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: Using @XLookupR instead of @Number
Reply #1 - Dec 19th, 2006 at 5:26am
Print Post Print Post  
1.  The XL functins will not work in Preview Mode, so be sure you are not in Preview Mode.

2.  The third parameter should be the name of the form, but it looks like the name of the element.
nextNumInt = @ToNumber(@XLookupR(@FN, "99999", "Receipt Number0", "Receipt Number0")) + 1

3.  If there is no existing record, then the first value back will be 0, so "00001" is exactly correct.
Are you sure you have a record with a value in ReceiptNumber0?

4.  Good programming practice is to always put an @Error statement after the XL family of functions:
If @Error Then {  WriteLn("No Match found")  }
Just a sample, should be more informative.
  



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



Posts: 54
Joined: Dec 19th, 2006
Re: Using @XLookupR instead of @Number
Reply #2 - Dec 19th, 2006 at 5:59am
Print Post Print Post  
Thanks!

It ended up being the Preview Mode thing.

FYI, I actually tried the name of the form for the third parameter and it didn't work, however it did as written, using the element name.  (??)  No matter, I'm just happy it works, but I thought you should know.

Your quick response was amazing and very appreciated.  Thanks again.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Using @XLookupR instead of @Number
Reply #3 - Dec 19th, 2006 at 12:46pm
Print Post Print Post  
Bob_Hansen wrote on Dec 19th, 2006 at 5:26am:
2.  The third parameter should be the name of the form, but it looks like the name of the element.
nextNumInt = @ToNumber(@XLookupR(@FN, "99999", "Receipt Number0", "Receipt Number0")) + 1


The third parameter is the name of the external element containing the value you want to match. If there is only one Form in your application, you can just use the element name.  If you have more than one Form, you must also specify the name of the form where the element can be found: MyForm!MyElementName
  

- 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: Using @XLookupR instead of @Number
Reply #4 - Dec 20th, 2006 at 5:46am
Print Post Print Post  
Aaargh! 
Thanks for the correction Erika.

I think I need to take a vacation, too many hours, too many incomplete answers.   Embarrassed
I need to force myself to make the time to test the answers before posting. 
I do appreciate you and Mark for keeping me honest.

PS - I did test this response first.
  



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