Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) baby step (Read 13976 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
baby step
Feb 12th, 2009 at 3:44pm
Print Post Print Post  
such a simple thing, I feel like I should ask it under an assumed name!

I have the following:
Form - Inventory
Form - Trucks
   subform - TLines

Inventory includes ItemNum and ItemDesc, and TLines includes TLItemNum and TLItemDesc.
       When adding a record in TLines, when I exit the TLItemNum field, I want the programming to find the matching ItemNum value in Inventory and then pull the ItemDesc value for that Inventory ItemNum and put it in the TLItemDesc field on my TLines form.  Where is my program off (currently when I add a record, it doesn't pull the ItemDesc into the TLItemDesc field) ?

.... on element exit ....

IF @add and TLItemNum <> "" then
     {
           XLOOKUP (@FN, "TLItemNum", "INVENTORY!ItemNum", "ItemDesc", TLItemDesc)
     }
  

Larry
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:  baby step
Reply #1 - Feb 12th, 2009 at 4:21pm
Print Post Print Post  
The code should be:

Code
Select All
IF @add and TLItemNum <> "" then
     {
	     XLOOKUP (@FN, TLItemNum, "INVENTORY!ItemNum", "ItemDesc", TLItemDesc)
     }

 



remove quotes from arround TLItemNum.
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #2 - Feb 12th, 2009 at 4:52pm
Print Post Print Post  
Thanks, Bharat! 

Unfortunately, that still didn't result in a successful lookup.  I must be missing something else - what/where should I look for my omission/mismatch?
  

Larry
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re:  baby step
Reply #3 - Feb 12th, 2009 at 5:35pm
Print Post Print Post  
Hello,

Please run the following two lines of programming in the On Element Exit event. If they do not display numbers greater than 0 in the Sesame Slate, then the element names do not exist in the external database.

Writeln(@CountStringArray(@XListValues(@FN, "INVENTORY!ItemNum")))
Writeln("==========================")
Writeln(@CountStringArray(@XListValues(@FN, "INVENTORY!TLItemDesc")))


  
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:  baby step
Reply #4 - Feb 12th, 2009 at 6:21pm
Print Post Print Post  
I believe you are working on the subform. All lineItems even though have the same name, they are differentiated by linenumber or Instance. instead of xlookup, you will have to use FormFieldValue ( ) to assign the value to the line item. Something like in the code below... I did not check the code but you will get the idea that subform works a little differently.

Code
Select All
var n as int
var vStr as String

n = @FormResultSetCurrentPosition ("SubformName")
//Please fill in the subform name

vStr = @XLOOKUP (@FN, TLItemNum, "INVENTORY!ItemNum", "ItemDesc")

FormFieldValue ("SubformName", "ItemDesc", n, vStr)

//Fill in the Subform name

 



  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #5 - Feb 12th, 2009 at 7:05pm
Print Post Print Post  
Ben,
        nothing but '0'.    I have dbl-checked the element names in the Inventory db, and they are ItemNum (text field) and ItemDesc (text field).

Bharat,

When I load the application, I get an error that says "Some or all of the programming in this form has  failed to compile.  No event programming will run"

I go to preview app, and when I enter an ItemNum and exit that field, I get the following message: "Error:  A runtime SBASIC error has ocurred.  Please close this form and repair the condition before continuing"
  

Larry
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:  baby step
Reply #6 - Feb 12th, 2009 at 7:41pm
Print Post Print Post  
Can please you post your code. What error does it show in the program editor?  Use the following code to see if it is getting the value from INVENTORY Layout. What is the name of the Database?


Code
Select All
var vStr as String

vStr = @XLOOKUP (@FN, TLItemNum, "INVENTORY!ItemNum", "ItemDesc")

WriteLn (vStr)


 

  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #7 - Feb 12th, 2009 at 8:30pm
Print Post Print Post  
Bharat,

your code resulted in a blank Sesame Slate popup window


I'll post my code and database.    By the way, should the ItemNum and ItemDesc fields in Inventory (the Source database) be 'bound' ?
  

Larry
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:  baby step
Reply #8 - Feb 12th, 2009 at 8:38pm
Print Post Print Post  
Quote:
I'll post my code and database.    By the way, should the ItemNum and ItemDesc fields in Inventory (the Source database) be 'bound' ?


Yes. They have to be.
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #9 - Feb 12th, 2009 at 8:40pm
Print Post Print Post  
Bharat,

//Trucks.db, with TruckLines.db as a subform of the Trucks.db
//Inventory.db  
     A dispatcher needs to build a picklist of products to load onto a delivery van.  So they create a new record in Trucks, and enter the items that need to be picked in the subform TruckLines.  I want him to input the ItemNum, and then have the programming find the matching ItemNum in Inventory.db and have the product description pulled from the Inventory!ItemDesc field and plugged into the ItemDesc field on the TruckLines subform (sales reps navigate with part #'s, but delivery drivers usually rely on the description field of the item).

//code (on element exit, entered on TLItemNum)

IF @add and TLItemNum <> "" then
     
{
     XLOOKUP (@fn, TLItemNum, "INVENTORY!ItemNum", "ItemDesc", TLItemDesc)
}


fyi, here is the programming I have in my QA Trucks database (STOCK = Inventory.db, and "PART #" = ItemNum) ...
>#50: XLOOKUP ("STOCK",#50,"PART #","DESC.",#51,"LOCATION",#52); GOTO #11
  

Larry
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:  baby step
Reply #10 - Feb 12th, 2009 at 8:50pm
Print Post Print Post  
Quote:
your code resulted in a blank Sesame Slate popup window


This means the @xlookup ( ) failed. The reason could be very well that those elements in Inventory Layout are not bound. Do you have the security in the database?
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #11 - Feb 12th, 2009 at 9:03pm
Print Post Print Post  
no security yet.

The elements are not bound at the present time.  Do I need to do so?
  

Larry
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:  baby step
Reply #12 - Feb 12th, 2009 at 9:13pm
Print Post Print Post  
Quote:
The elements are not bound at the present time.  Do I need to do so?


Yes. That is a must. xlookups would not work without that.

Also if you are trying to place a value in the element of the subform, you will have to use FormFieldValue( ) as there several instances of the same element the subform as there are multiple records in subforms each has Itemdesc. This is very much evident when you have Tableview subform.  Am I making sense?

1              Itemdesc
2              Itemdesc
3              Itemdesc
  
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:  baby step
Reply #13 - Feb 12th, 2009 at 10:05pm
Print Post Print Post  
lksseven,
If the element in the Layout is not bound to the field of the underlying database that means it does not store any value in the database. Such unbound text elements are used to display the calculated value that does not required to be stored.

Also note that there are new terms when you come from Q&A background that you should be very clear about, such as

Application
Database
Field
Layout
Element

All these terms have distinct meanings.
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #14 - Feb 12th, 2009 at 10:26pm
Print Post Print Post  
Bharat,

re:  itemdesc
     itemdesc
     itemdesc


yes, but since it is pulling the description for the unique ItemNum on that line, then it would still pull the correct description, no?   (I'm not trying to argue, just trying to understand.  I want to have a solid understanding of 2+2=4, so that I can build from there)
  

Larry
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print