Combobox Rowtagat

I’ve decided to move from Ms Access to Xojo programming and naturally there are new concepts that I need to acquire, despite some similarities between Realbasic and VBA.

At the moment I’m struggling to retrieve the rowtag from a combobox control.

I set it right after the adding a new row, and the combobox populates correctly, but when I try retrieve the Rowtag associated with the selectedrowindex I get a blank value. Instead, for testing purposes if I retrieve within the populating loop I get the correct value.

var Paises as rowset

try

  • Paises = App.BaseDados.SelectSQL(“SELECT DESC_PAIS As Pais,ID_PAIS FROM tGE_Paises ORDER BY DESC_PAIS”)*
    catch error as DatabaseException
  • messagebox(error.Message)*
    end try

Dim i, n as integer

i=0
n=paises.rowcount

While i<=n

  • Pais.AddRow(Paises.Column(“Pais”))*
  • Pais.RowTagAt(i)=Paises.Column(“ID_PAIS”)*
  • paises.MoveToNextRow*
  • i=i+1*
    wend

Is it a scope related issue? What am I missing here?

Could you please wrap your code in code tags?

It’s three backticks ``` then a new line, then your code, then three more backticks.
You can also select the code and click the </> icon in the post editor.

The forum text formatting is mangling your code.

Update: I’m not able to reproduce a problem with RowTag, you can check out this example project: ComboBoxRowTag.xojo_binary_project

Tim,

Sorry, the codes is as follows:
indent preformatted text by 4 spaces
var Paises as rowset
try
Paises = App.BaseDados.SelectSQL(“SELECT DESC_PAIS As Pais,ID_PAIS FROM tGE_Paises ORDER BY DESC_PAIS”)
catch error as DatabaseException
messagebox(error.Message)
end try

Dim i, n as integer

i=0
n=paises.rowcount

While i<=n
Pais.AddRow(Paises.Column(“Pais”))
Pais.RowTagAt(i)=Paises.Column(“ID_PAIS”)
paises.MoveToNextRow
i=i+1
wend

indent preformatted text by 4 spaces
Pais.AddRow(Paises.Column(“Pais”))
Pais.RowTagAt(Pais.LastAddedRowIndex) =

simpler without i
While Not paises.AfterLastRow

Thanks! Made more clear but my problem while retrieving the Rowtagat still remains.

Tim,

I’ve looked at your code, and mine should work as well.

I’ve a rowset with tow fields DESC_PAIS (countries name Varchar(50)) and ID_PAIS (country ID Varchar(2)), the DESC_PAIS is used in the add row value, and ID_PAIS should be the Rowtag of the added row.

I get not error while populating the combobox, but in the change event of the combobox I test to get the rowtag with no sucess!

<Dim i as integer

i=me.SelectedRowIndex

messagebox(me.rowtagat(i))/>

can you test it with Paises.Column(“ID_PAIS”).IntegerValue

Markus,

Yes! Solved, not wit the integervalue but stringvalue since the field ID_PAIS it’s a VARCHAR type.

Thanks both of you.

1 Like