View Single Post
  #1   Report Post  
BizMark BizMark is offline
Member
 
Location: London
Posts: 78
Default DrawingObjects/AutoShapes' .OnAction property in DialogSheets

Dear All,

I have a DialogSheet which contains a 'date chooser' screen.
It contains a grid of textboxes which, in the top row contain "Mon, Tue, Wed, Thu"... etc and in the following rows, the numbers 1-28/29/30/31 (depending on how many days in the month).

There are actually 31 date boxes, but the dates are put through a Format(DATE(day,month,year),"dd") function to test whether the result matches the supplied day. In this way if the result DOESN'T match, (i.e. for 29, 30 or 31 days in February) I set the Interior.ColorIndex to 'white' (which has the effect of hiding the number).

All that works fine and dandy.

However, each textbox has a routine set to its .OnAction property which sets the selected date box as a date to search for in a data sheet. This other routine highlights the selected text box by colouring it blue (unselected boxes are coloured black) and also converts the selection to a date value which is returned to the dialogsheet in a textbox and used by the calling routine to determine the date to search for.

In Excel 95 when this DialogSheet was first created, clicking on the textboxes worked every time. On moving to Excel 97 I found it worked almost all the time but on occasions, the textboxes would not be clickable or get focus - so the .OnAction event would not trigger and the routine would not run.

On moving to Excel XP and 2003 I have found that this DialogSheet ALMOST NEVER works. However, there ARE rare occasions when it does.

I can't seem to find a pattern to this - I have tried setting the focus to controls either side of the textboxes and/or moving through them by tabbing - I can TAB onto the textboxes then press SPACE to invoke the .OnAction event, but clicking on them with the mouse has no effect.

I know I really should re-create the dialog as a UserForm, but I would like to know whether there is some workaround or perhaps a simple explanation, perhaps there is a single line of code I could write into the routine before the .Show instruction to ensure the textboxes are always active.

(Note - when the dialog is shown, a routine is run which checks how many days there are in the month, and colours the date boxes accordingly, as described above. Also, for non-applicable dates, the .Enabled property is set to False. However for all applicable dates, the .Enabled property is actively set back to True.)

BizMark