Hot Topic (More than 10 Replies) baby step (Read 13978 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
 
lksseven
Full Member
***
Offline



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

I appreciate your help!!!!!

so my application, wc2.db, is comprised of the following databases:
Client
Inventory
Orders (subform SOLines)
Purch (subform POLines)
Pricing
Vendors
Trucks (subform TruckLines).

so if I want to have TruckLines (subform to Trucks) pull from Inventory!ItemDesc, should the Xlookup programming begin (@fn .....  ?
        

btw, I have bound those fields, and still no joy.

Obviously I have miles to go.  I promise I won't be this wordy/needy after I get past 2+2=4  Cry
  

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



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #16 - Feb 12th, 2009 at 10:47pm
Print Post Print Post  
yikes, hold the phone.   I think my wc2.db was locked.  I unlocked it - let me try the programming again.  I'll report back.

Undecided
  

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



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #17 - Feb 12th, 2009 at 11:09pm
Print Post Print Post  
it worked.   Unlocking the wc2.db and then binding the fields to the elements, and then re-entering the programming worked.

Sorry for my brickhead - I feel like a raw recruit on the first day of rifle training (hey, Sarg, what's this thing do?   "Bang!" )

Bharat, I still don't understand the drawback of using xlookup to pull in the ItemDesc that accompanies ItemNum.
  

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 #18 - Feb 12th, 2009 at 11:35pm
Print Post Print Post  
I am glad it worked for you.

xlookup ( ) command will place the value in the ItemDesc element...  but here in the subform there are many elements named ItemDesc, one per each lineItem or record in the subform. That is why the Fieldvalue of ItemDesc element in first record is @FormFieldValue ("TruckLines", "Itemdesc", 1).  Now when you want to assign the value you have to use FormFieldValue ( ).  The same as difference between @xlookup ( ) and xlookup ( ).

I am not very good at explaining. I am sure someone will step in and do a lot better job.
  
Back to top
 
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #19 - Feb 12th, 2009 at 11:55pm
Print Post Print Post  
I will read up on @FormFieldValue this evening.

Have a great evening!
  

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



Posts: 218
Joined: Apr 7th, 2005
Re:  baby step
Reply #20 - Feb 13th, 2009 at 6:44pm
Print Post Print Post  
Quote:
xlookups would not work without that.


Bharat,
If the programming is in the subform referencing the subform lksseven will not need to use FormFieldValue. @XLookup or the XResultSetValue command would work.
  
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re:  baby step
Reply #21 - Feb 13th, 2009 at 7:25pm
Print Post Print Post  
Thanks, Ben!

Bharat,  your advice was put to good use - I was studying up on FormFieldValue last night and have a much better understanding of it now.  Thanks for the pointer.
  

Larry
Back to top
IP Logged