Submitted by markfoley on 2009/06/15 02:22
I'm doing a little test of the VB editor, and see that the functions tend to refer to field values of the item currently active.  I do see some aggregation items like 'Sum' etc.
 
--> Is it possible to iterate through the items in a grid or indeed iterate through all items?  (eg foreach loop)
--> How to refer to items by ID?  For example, if I wanted to obtain an item's text and its parent's text I might want to do something like (pseudocode):
 
get thisitem(ID)
msgbox  (this item's text)
 
for each parent of this item get it's ID number
msgbox (parent's item text)
next parent
 
 
None of this is very core to a particular task I need to do presently- but these are common things I believe you'd need to do to manipulate your items beyond 'field to field' triggers.

Comments

gregory

2009/06/15 14:39

In reply to by Pierre_Admin

Hi Pierre.
 
My casual glance at the code visible in the existing VB window suggests that you are NOT currently exposing any object model and that in fact we cannot access field values elsewhere in the grid, for now.
 
Presumably VSTA will give you the opportunity to decide what parts of the IQ object model you wish to expose. It will be great to be able to do things like SQL SELECT tableSubcategory.subcategory FROM tableSubcategory WHERE tableSubcategory.category = <currently selected category in grid>
 
Or is this already possible? Would it be possible to document the syntax and available semantics of SQL a little further, or is it better to keep all the detail hidden until you move away from Microsoft Access database management to MS SQL Server, MySQL, whatever?
 
There I go again... wanting to run before I can walk!
 
Mark Gregory, Rennes, France - GMT +1/+2; EST +6

Pierre_Admin

2009/06/15 15:28

In reply to by gregory

>My casual glance at the code visible in the existing VB window suggests that you are NOT currently exposing any object model and that in fact we cannot access field values elsewhere in the grid
 
This is correct. Currently you can access one of:
  • any field value of the current item (equation, auto-assign)
  • a field value of all subs (Hierarchy equation)
  • a field value of all parents (Hierarchy equation)
 

markfoley

2009/06/15 23:03

In reply to by Pierre_Admin

Thanks for that Pierre.  I created another thread about how we might access those parent values for searching purposes.
 
Cheers

gregory

2009/07/28 02:53

In reply to by markfoley

I have raised Mantis issue 0759: VBA code not working:
 
"
VBA code does not appear to work.

I have added functions to the User Code section of the VB Editor. These are not recognised when referred to in the 'Execute a function' immediate-execution box or in row equations.

Thus date(), a built-in VBA function, works; but
Function before(look_for, search_in, first_or_last)
'This function returns the part of the searched_in string before an occurrence of a looked_for string.
'By default, this is the first occurrence of the string; an optional parameter can be set to indicate that
'the last occurrence is sought - the default is to take the first occurrence.

does not work.
I have a suspicion that this bug has been introduced by release 0.9.24, which separated system code, user code and this database code.
"
 
You have previously suggested that you will be using the new version of Microsoft VBA, called Microsoft® Visual Studio® Tools for Applications (VSTA) (VBA licensing is no longer possible.)
 
Is this a major change, and if not, can it be done soon? Because the existing VBA code feature, even when it works, provides a very limited development environment and opaque / incomprehensible error messages.
 
Mark Gregory, Rennes, France - GMT +1/+2; EST +6