#7761
Support 1
Participant

You are welcome; we are always happy to help whenever possible with developers’ questions.

I think ADOObj is no longer accessible because the variable used to reference this object goes out of scope. You will notice in the example you mention that Sub Main() declares the local variable:

  dim iADOObj

Also in Sub Main(), this variable is passed to other subroutines which work with the database connection, eg.

  case Btn5 EditRecord(iADOObj)

By passing the object reference to each subroutine that needs the reference, the solution ensures it is always accessible until the time comes to close the connection.

An alternative method is to declare a global variable (outside all subroutines/classes), usually at the beginning of the source code – before Sub Main(). Then all subroutines and class methods have access to the variable.

On your question about RzRadioGroup, I think it would be easier if the index (not the text) is stored in the database. This would help with supporting different human languages; then the text only appears in the user interface.

However, if your existing database stores the text, you will have to search the radio group for the item text to determine its index. If there are many items and the search is slow, you could add a “lookup table” to your solution. This might be a StringList object initialized from the radio group:

  dim I
  dim iLookup

  ' Notice how the index (I) of each radio item is stored in the StringList
  ' as the Object associated with the item text:
  set iLookup = Utilities.StringList
  iLookup.Sorted = true
  for I = 0 to RadioGroup1.Items.Count - 1
    call iLookup.AddObject(RadioGroup1.Items(I), I)
  next

Then, to look up the index for a given item’s text:

  dim I

  if iLookup.Find(iItemText, I) then
    RadioGroup1.ItemIndex = iLookup.Objects(I)
  else
    RadioGroup1.ItemIndex = 0
  end if

See the Formativ Language Guide for details on using StringList.

I hope this helps.

Regards,
Advansys Support

[This message was edited by Support 1 on October 23, 2006 at 05:52 PM.]