Trouble with wrong window opening

I have an app that has two windows which have practically the same controls on each. The controls that are different are the buttons, because one window is for adding customers to a database, and the other window is for editing existing customers and updating the database.

Of of the controls which is on both windows is a checkBox, which I have subclassed.

Here is the code in the Action Event:

If Me.Value Then If Window(0) = addCustWindow Then addCustWindow.qtyText(Me.index).Enabled = True Elseif Window(0) = editCustWindow Then addCustWindow.Close ******************* EditCustWindow.qtyText(Me.Index).Enabled = True End If Else If Window(0) = addCustWindow Then addCustWindow.qtyText(Me.Index).Text = "1" addCustWindow.qtyText(Me.Index).Enabled = False ElseIf Window(0) = editCustWindow Then editCustWindow.qtyText(Me.Index).Text = "1" editCustWindow.qtyText(Me.Index).Enabled = False InvoiceDatabase.SQLExecute("DELETE FROM standing_orders WHERE client_id = " + Str(Customer.getCustSelection) + " AND standOrder_type = " + Str(Me.Index) + "") If InvoiceDatabase.Error Then MsgBox(InvoiceDatabase.ErrorMessage) End If addCustWindow.Close ********************* End If End If

The asterisks are not included in the code. They mark the lines which solves my dilemma. The add customer window works fine. But when I click on a checkbox in the edit customer window, the add customer window opens in front of it. By closing this window, everything works perfectly.

So on the Mac, closing the add customer window works. But it doesn’t on Windows (which is where this app is destined for).

So, can someone tell me either what I am doing wrong, or perhaps tell me another way to open which ever of these windows I require at the time.

Thanks in advance.

Using “=” in your test causes the window to be instantiated. Use “IsA” and type casting instead.

    If Window(0) IsA addCustWindow Then
      addCustWindow(Window(0)).qtyText(Me.index).Enabled = True

Thanks Tim

Working with Objects is coming to me slowly, So thanks for another part of the mystery.