It's time once again to check in with our dear colleague Colin A. Bradley. If you remember from previous posts, Colin is apparently the victim of some cruel practical joke known as the accounting system Payback. While maintaining this treacherous application, Colin came some tables of the following form ...

"A_ID seems a reasonable column name, indicating the primary key of A. But what about "A_IX?" What the hell might that be used for? Looking at a cheat sheet that some previous developers had made which maps the cryptic field names in this database to more sane names, I see that the "IX" in "A_IX" stands for "Index." Now I'm curious ... so I locate the VB6 code accessing this ...

 

Public Sub Form_Load()

  '...

  With Rsets(1)
    Do While Not .EOF
      Me.cmbAccts.AddItem .Fields("A_TX").Value, .Fields("A_IX").Value
.MoveNext() Loop End With Me.cmbGLAccts.ListIndex = True '... End Sub

 

"In case you're not hip to VB 6's jive, the AddItem method of the ComboBox control accepts the item that you would like to add to the control's list, and, optionally, the position at which you would like that item to be inserted into the list.

"So we see here that the original developer thought it would be a good idea to store the alphabetical order of items in this ComboBox control explicitly in a column in the database (and rely on the combobox to handle the ORDER BY). And after a little more searching, I can confirm that this exact method is used for other tables in this database.

"What's also interesting to note is the last line setting the ListIndex to True; the ListIndex property of a ComboBox determines which item in the list is selected. As it turns out, the VB code was just too easy to follow on its own, so our seasoned veteran had to take advantage of the fact that True converts to "-1" as a number. This effectively caused no item to be selected in the list; which it wouldn't be anyway in the Form_Load method ...

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!