Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
jarno_loubser
Partner - Creator
Partner - Creator

Read multiple fields from the same record in a resident table using macro code

I am looking for a macro function that can read multiple fields from the same record in a resident table into an array...

What I have is:

KeyItemAmount_InputQty_InputPrice
0ABC11001010
1BCD1200540

Amount_Input and Qty_Input are Input Fields and the user can update these on the front end using InputSum. When either of these are updated the other Input Field must be updated using the Price (Amount_Input = Qty_Input * Price and Qty_Input = Amount_Input / Price). This does not have to happen realtime as the user only sees one Input Field at a time.

The requirement has already been met by using a Straight Table object, conditional expressions and a macro that loops through the Straight table object and sets the Input Cells one by one using "SetInputFieldCell". I have however found this method to be too slow.

I would like to use "SetInputFieldValue" to update the values as tests have shown this to be much faster than the front end alternative.

The problem is I do not know how to get the entire record (see above) into one array.

Any help will be appreciated.

3 Replies
marcus_sommer

Not clear wherefore you need a array, please post your code.

- Marcus

jarno_loubser
Partner - Creator
Partner - Creator
Author

See sub below...

Note that this code works and currently updates all ForecastQty (in my selections) to 777777, but it needs to update the value of ForecastQty on each record to the value of ForecastValue / x on that same record...

sub TestUpdate

  set fldpos = ActiveDocument.Fields("SalesForecast_Key2").GetPossibleValues(1000000)

  set fldInpQty = ActiveDocument.Fields("ForecastQty")

  'set fldInpVal = ActiveDocument.Fields("ForecastValue").???????????????????????????????????

  for i = 0 to (fldpos.Count -1)

  origid = fldpos.Item(i).Number

  'newQtyVal = fldInpVal.Item(origid).Number / x

  fldInpQty.SetInputFieldValue origid, "777777" 'newQtyVal

  next

end sub

marcus_sommer

It seems you want change a very large amount of data - this will always need some time. To synchronized fields is difficult because the field-values are always distinct. Should you find ways with some intermediate steps like counting, sorting ... it will be rather not faster as your solution with "SetInputFieldCell".

What is your intend to change these field-values. QV split automatically the sum-values in all corresponding items and further calculations could be make with variables.

Perhaps there are alternative possibility. You could separate the objects in which users make entries and which are used for anaylses.

- Marcus