-
Hi.
I have an array of command buttons. A `case select` command splits them into cases. At the end of case (6) i want to cause case (7) to be called. I`ve tried calling Click1_command and i get very strange results. It looks like its getting the scope of things wrong. Ie, the default `me` i assume it uses maybe points to the wrong form, as it checks to see if certain controls have valid data.
Ie, in case 7, the code checks to see if all the fields that should be filled in are being filled in. When i invoke case 7 in the usual way, it works, but when i invoke it from case 6, it complains. It then puts up a requester, and doesnt wait for a mouse click, then quits (as if i hit escape). Very strange. I assure you that all the code works without this new invocation.
I`ve tried putting `me.` or `frmname.` before the command1_click(7) call, but it doesnt even compile then (method or data member not found).
Any ideas? Can you invoke events in this way, or is it Bad?
Thanks,
Alex.
-
If you have a control array of Command buttons then you would have to call the event, passing the index of the 7th button:
Code:
Select Case intIndex
Case 0 to 4 'First 5 buttons
'Do your stuf here
Case 5 'On sixth button call Click event for the 7th button
Call Command1_Click(6)
End Select
-
Sorry sorry sorry...my mistake... theres an `Unload Me` command BEFORE i invoke the command1_click(7) event... so i`m calling an out of range event in the previous form, i imagine (theres no `case 7` in that one...).
I`ll fix this, and have a little think about how to prevent this in future. Of course, if it let me compile :
frmname.command1_click(7) then presumably it`d be possible to check, at run time, whether frmname exists any more?
Sorry again,
Alex.