View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Geoff[_12_] Geoff[_12_] is offline
external usenet poster
 
Posts: 7
Default Firing Click Events with Accelerators

Hi
In short - still no. In both cases the optNo proc completes but without
calling for HideControl. Therefore no error is generated but the buttons
remian visible.

One thing I had not mentioned before; my original code for optYes_Change
included a LookUp function. Since using the GetAsyncKeyState code I have had
to place this function in the new optYes_Enter event else an error was
generated in the optYes_Change event

Private Sub OptYes_Enter()

If GetAsyncKeyState(vbKeyMenu) And &H8000 Then optYes.Value = True
OpenSpeedo = WorksheetFunction.VLookup(cboVehReg.Value,
Sheets(3).Range("G1").CurrentRegion, 3, False)

End Sub

It seems as though only certain things can be done within the optbutton
change event under these circumstances. In numerous new code tests I have
also had problems with SetFocus statements. The curious thing of course is
the original code worked with the mouse.

The differences in execution a in the mouseup event, focus will be
directed to the optbutton, disregarding where it was prior to the click, the
procedure completes but focus is not returned to the previous position. In
other words the mouse click forces a 'GotFocus' condition. Maybe with the
GetAsyncKeyState code, focus may well be only diverted and the previous
control has not 'LostFocus'. This might explain the SetFocus problems. But
I do not understand why some statements are executed in the optNo proc. What
is different about Visible and VLookup. With VLookup it seems reasonable to
propose that focus is being switched to another object ie the worksheet but
can that be said of the Visible property?

I shall focus my efforts on focus mechanics:):)

Thanks so far

Geoff
"okaizawa" wrote:

Hi,

Geoff wrote:
I too thought it may be a timing issue but the interesting thing now is the
HideControl sub is not being called. There is no error now as the proc is
not being called and therefore there is no attempt to hide the buttons. It
is at the hide point the Visible error occurs.


set a break point on the line:

Application.OnTime Now(), "HideControl"

If the macro stops at the point, the procedure name might be different
or conflict.
try something like:
(assuming 'HideControl' is in 'Module1' in the same workbook)

Application.OnTime Now, "'" & ThisWorkbook.Name & "'!Module1.HideControl"

--
HTH,

okaizawa