SetFocus from the code module of another form?
The code below worked a few times during the development of my new application, which is far from finished. Now the compile results in an error message (Invalid procedure call or argument) for the first of the two bold lines below.When I make the first bold line above into a comment, the compile works with no error messages. TxtCell is a Control Array mostly generated at Run-Time. TxtCell(0) exists at design time.VB Code:
Private Sub cmdClear_Click() Call ArrayResetter SquareResetRequired = True ArrayChanged = False [B]frmSquare.txtCell(0).SetFocus[/B] End Sub Private Sub cmdFill_Click() [B]. . . .[/B] ‘A Select Case with some Call Statements not shown here Call SquareSummer ArrayChanged = True SquareResetRequired = False [b]frmSquare.txtCell(0).SetFocus[/B] End Sub
The application uses two ordinary (not Midi) forms and a code module. The above code in the code module associated with one Form (frmcontrol), which activates the other Form (frmSquare) by setting focus to a Text Box on the second form. When the first bold line is changed to a comment, the code compiles, and the second form is activated by (I assume) the action of the second bold line.
I have changed the order of the two subroutines and the same code causes the error message. I have used copy/paste to make certain that the two statements are identical. I am pretty sure the code complied a few times before the trouble started. I forget which code was added just prior to the problem. The code added was in other procedures, so it is hard to imagine that it had any effect.




Reply With Quote