Module property changing

I have two comboboxes.
comboboxfile - contains the name of files to search
comboboxfield - contains the fields to search according to the file selected above

the first entry is always “”

I save the data to an InternalUse table so that when the user starts the application again they can return to where they left off.

The first MsgBox(ModuleInternalUse.LastReportsFieldSelected) shows “LensID” which is what was saved.

The second MsgBox(ModuleInternalUse.LastReportsFieldSelected) shows “”

I cannot find where it is being changed. Does anyone spot the problem?

[code] ModuleInternalUse.LastPrintDataTabSelected = rs.Field(“LastPrintDataTabSelected”).IntegerValue
ModuleInternalUse.LastSessionDataTabSelected = rs.Field(“LastSessionDataTabSelected”).IntegerValue
ModuleInternalUse.LastTabSelected = rs.Field(“LastTabSelected”).StringValue
ModuleInternalUse.LastReportsFieldSelected = rs.Field(“LastReportsFieldSelected”).StringValue
ModuleInternalUse.LastReportsFileSelected = rs.Field(“LastReportsFileSelected”).StringValue

// first msgbox

// set last reports file selected
For i = 0 To ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxFiles.ListCount - 1
If ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxFiles.List(i) = ModuleInternalUse.LastReportsFileSelected Then
ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxFiles.ListIndex = i
End If

// second msgbox

// set last reports field selected
For i = 0 To ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxField.ListCount - 1
If ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxField.List(i) = ModuleInternalUse.LastReportsFieldSelected Then
ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxField.ListIndex = i
End If


  • to see if there’s some place in your code that is changing the value, simply change the name of the property (e.g. from “LatReportsFieldSelected” to “LastReportsFieldSelectedXXXX” and recompile. You’ll get a syntax error any place it’s being used.
  • don’t use msgbox to debug, as that can cause window activation/deactivation events. Use system.debugLog instead.
  • change LatReportsFieldSelected from a property to a Computed property, and set a breakpoint on the Setter.
  • combo boxes may get spurious change events before the window is fully open - set a breakpoint there and step through the code to see what’s going on.

Michael, thank you for the recommendations.

I’ve done the first one.

On your last point, the combo boxes may get spurious change events, but would a module?

Modules don’t get any events, as far as I know.

When are you calling this code to set the ComboBox value? You probably want to wait until after the Window Open event is called.

Also, you could make your code a bit more readable with a temporary variable for the ComboBox, as follows:

  dim cb as comboBox = ContainerControlSessionData1.ContainerControlReports1.ContainerControlReportsLeft1.ComboBoxFiles
  For i = 0 To cb.ListCount - 1
    If cb.List(i) = ModuleInternalUse.LastReportsFileSelected Then
      cb.ListIndex = i
    End If

What I meant was a module property. Anyway, I’ll keep checking. Thanks.