Start a new topic

how to get a vitual field to update via VB



We’re using IOM with RE (7.96)


I’m trying to understand how to use the API Code editor with Virtual Fields – I’m experienced at VB, but in MS Access 


The idea is:


if a field in an import file has a “Y” in it, update a variable field with the date (to set the cons attr date field)


My VB Code is ok  for example


    If Import.Fields.GetByExcelName("I").Value = "Y" Then

  Import.Fields.GetByExcelName("AB").Value = Now()

  Else Import.Fields.GetByExcelName("AB").Value = ""

  End If


But I can’t get it to update the virtual field. In the help docs it says about virtual fields – in Function it could be a standard function, a copy field OR


“Custom function -  Users who have programming skills can create their own functions using IOM’s API feature. “

Under the Function Drop down I don’t seem to have a “Custom” option (see attached) how do I choose this option (or what option should I use with a virtual field to be updated by VB)?



Hi Mark,

Your code looks good, I think you just need to update line 2 to 

Import.Fields.GetByExcelName("G").Value = Date.Today

You can build custom functions but that isn't really relevant to what you're trying to do.  In your virtual field don't set a function at all since the code is essentially processing a "function" for you.  Just map the field to the gift attribute date and leave the function as None.



Hi John - thank you so much for the code change - I've updated the VB so it says

 If Import.Fields.GetByExcelName("I").Value = "Y" Then
 Import.Fields.GetByExcelName("AB").Value = Date.Today
 Else Import.Fields.GetByExcelName("AB").Value = ""


the virtual field  ("AB") function  is set to NONE  (Record Type is Set to Constituent Attribute Date  and Field I for the Value Type)


but when I test the code  the virtual field doesn't update to the date


I just copied your code and and pasted it into a random profile (changing nothing) in the before dictionaries subroutine and it worked.  Do you have any dictionaries applied to AB?



Interesting and reassuring!

"Do you have any dictionaries applied to AB?"

No, not to AB, but I do have a dictionary applied to I... I'll have a play with that and see if the dictionary is causing a problem


First off my code was in the "after dictionaries" section in the module so looking for a "Y" in the incoming data (which had, at that point, been modified by a dictionary) didn't work so I've changed that (and also realised that even though I'd been saving the code, I wasn't saving the IOM template so it wasn't seeing my changes anyway). All n00by pebkas related. :)

Ah I feel I have learnt something today - Thanks for all your help, John!

Now... to make it make me a cup of tea.... ;)

Login or Signup to post a comment