Normal Topic @Tonumber(@XLookupR() question (Read 863 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
@Tonumber(@XLookupR() question
Mar 15th, 2004 at 10:57pm
Print Post Print Post  
Could a Lantican or  a user please clarify on the proper syntax to use with this code regarding form!field

A shy forum member had a problem using this code and I volunteered to check it out (they may be sorry I offered to help)

They have a file structure that looks like this

NewSesame
     Forms
           Add Data
                 Customer Data
                       Form1
                       Form2
                 Invoices
                       Inv Data
                 Prod
                       Prod

This worked fine to generate there customer number

If  cusnum = ""  Then
      cusnum = @Tonumber(@XLookupR(@Fn, 999999, "cusnum", "cusnum")) + 1

However this would not work to generate an invoice number

If InvNum = ""  Then
      InvNum = @Tonumber(@XLookupR(@Fn, 999999, "InvNum", "InvNum")) + 1

By adding the form name like this it now works

If InvNum = ""  Then
      InvNum = @Tonumber(@XLookupR(@Fn, 999999, "inv data!InvNum", "InvNum")) + 1

But I can not explain to them how to get the next level to work. We tried

If ProdNum = ""  Then
      InvNum = @Tonumber(@XLookupR(@Fn, 999999, "prodNum", "prodNum")) + 1

and then

If ProdNum = ""  Then
      InvNum = @Tonumber(@XLookupR(@Fn, 999999, "prod!prodNum", "prodNum")) + 1

and then

If ProdNum = ""  Then
      InvNum = @Tonumber(@XLookupR(@Fn, 999999, "prod!prod!prodNum", "prodNum")) + 1

So basically I am asking what is the rule of thumb to follow with this logic and form names. Or were have we gone wrong.

Thanks All.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @Tonumber(@XLookupR() question
Reply #1 - Mar 15th, 2004 at 11:22pm
Print Post Print Post  
I'm going to start with some questions and try to drill down to the actual problem.

1. Why are you trying to set InvNum to a product number?

2. From which Form is this code running?

3. Is the LE on the Prod form named prodNum? Note: The LE not the underlying field.

4. When it "doesn't work", what happens? Does it return nothing? An incorrect value?
  

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


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: @Tonumber(@XLookupR() question
Reply #2 - Mar 15th, 2004 at 11:47pm
Print Post Print Post  
1

Lousy typing. I was trying to make there form generic before I posted the question because I did not have there permission yet to share it with others and made a typo. in the actual database it is correct.

2

I tried it from the prod form first without success.

3

yes

4

Nothing at all

I have added this type of  layout to my test database and am having the same results. I can get the first 2 branches to work but not the third. But I might be practicing the same mistake. Should the form name followed by the bang then LE be correct?

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @Tonumber(@XLookupR() question
Reply #3 - Mar 15th, 2004 at 11:57pm
Print Post Print Post  
Try two things for me:

1. 
If ProdNum = ""  Then
WriteLn("I RUN")

Did the WriteLn happen?


2.
WriteLn(@XLookupR(@Fn, 999999, "prod!prodNum", "prodNum"))

Did the WriteLn produce anything?
  

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


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: @Tonumber(@XLookupR() question
Reply #4 - Mar 16th, 2004 at 12:15am
Print Post Print Post  
Well I am not sure if this is good or bad thing but before I saw your latest response I deleted the LE and the underlying Field and started over and now it works.

I do not know if it was a typo or something else. I will ask for another copy of  the database that is not working and see if I copy the code from the working one to the non working one what happens.

Sorry. It seems like a ruined the trail back to find the problem.
  

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


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: @Tonumber(@XLookupR() question
Reply #5 - Mar 16th, 2004 at 2:52pm
Print Post Print Post  
I have not gotten another copy of the problem database yet, However In my test database I thought I recreated the same problem but it seems that when I start from scratch with a new LE my problem no longer exists. I am beginning to suspect the problem is of my own doing, like typos or incorrect le or form name.

I am learning that one of the biggest tools a programmer has to use is time and patience. I find that small little errors like typos or even being on the wrong dsr or reconciling to the wrong db is not uncommon to the inexperienced programmer. I am so busy paying close attention to syntax or structure I miss the obvious. I would probably solve more of my problems faster by walking away for a few minutes and coming back with a clearer outlook instead of working non stop to find a solution.

Sorry for the wild goose chase.   Embarrassed
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged