How to make click & drag time input

  • Thread starter Thread starter Steve
  • Start date Start date
Any ideas?

Please...

What you are after can be done but it will require a fair knowledge of VBA.
I have a small db which demonstrates the technique you can download from -
www.bestfitsoftware.com.au/downloads/access/bfGridDragAndSelect.zip

The basic idea is that you build a form consisting of a grid of labels. Each label represents a time period. So for example to display all half hour
time periods for a week you would have 7 rows of 48 labels, one row for each day.
Each label must be of identical height and width and must butt together perfectly. You store the height and width of the labels (in twips) as a
constant and use these values to calculate which labels have been crossed as the mouse moves.
Each label should be named in such a way that the name represents its corresponding time period. eg in my demo all labels are named in the format
"D" - day - timeperiod so a label called D322 represents day 3 / timeperiod 22.
Build a lookup table to record the time periods eg 1 = 12am to 12:30am to 48 = 11:30pm to 12am.

The highlighting has 3 steps
1. The MouseDown event stores the x,y co-ordinates of where in the label the mouse was clicked.
2. The MouseMove event continually calculates the current position of the mouse in relation to the starting point. Using this calc you determine when
a border has been crossed to determine which labels to highlight / dehighlight.
3. The MouseUp event calculates the end point of the drag and calculates and highlights all labels between the start and end points of the drag.

The details of the drag are written to a type array. You can then loop the array and write the values back to a table.

The code is not super complex. The main problem is that because Access doesn't support control arrays the code must be added to each label
individually 7*48=336 labels = a lot of copy and pasteing ;-)


Wayne Gillespie
Gosford NSW Australia
 
Back
Top