Creating objects at runtime

L4serK!LL

Registered User.
Local time
Today, 11:19
Joined
Jul 22, 2002
Messages
59
I want to draw up a timeline on a form...
I was thinking of drawing rectangles in a row, representing time intervals...

Would like to have it look something like this:


||||||||||||||| |||| |||||||| |||||||||||


However I don't know how to create those rectangles at runtime :(

Who helps me out?


Thanks in advance


PS: Perhaps there is a way of doing so without the use of VB code (i'm thinking of graphs) which I haven't figured out?
I know it's possible on reports but has to be on a form :(
 
If you know how to code it for reports, you also know for forms. Code should be the same (create a text box and resize it at runtime by setting its Left and Width properties), only events should differ.
 
Last edited:
But how do I create those rectangles then?
It has to be put in while/wend-loop...
How can I make sure an (in theory) infinite number of rectangles is allocated, declared and initialised?

Could you give me an example code part for that?
 
Without further details it is not possible to provide more help. Explain the context, data in cause, what exactly you want to do and what you have in hands (form(s)).

BTW infinites, as you say, only exist in theory. No chance that you ever run into related pb with Access. And in the meantime you should have a look to Left and Width properties in Access help to make yourself an idea on 'how to'.
 
Alexandre said:
Without further details it is not possible to provide more help. Explain the context, data in cause, what exactly you want to do and what you have in hands (form(s)).

BTW infinites, as you say, only exist in theory. No chance that you ever run into related pb with Access. And in the meantime you should have a look to Left and Width properties in Access help to make yourself an idea on 'how to'.
I got a table with events that have a date + start + end time + some extra insignificant fields.

The user chooses a date and then I want an empty form to show one (interrupted) line (that's what the rectangles are for) that shows the time intervals for that date during which events have taken/will take place...

Controle = CreateControl(Me.Name, acRectangle, , "", "", Me.boxMaxDays.Left + (intStartDayDiff * sngFactor), , intDayDiff * sngFactor causes me problems because it says I can only create controls in the design environment :(

Is there a way to pass around this or another possibilty to achieve my goal?
 
Isn't there any premade Timeline Control available that I could use?
 
If you can foresee a maximum number of segments you would create them right from the beginning, make them invisible, and save your form like that. Then at run-time based on a count of the records you have you would make a loop to set those textboxes visible and resize them. This does not require to open the form in edit mode.

If not, you can display the hourglass and disable the screen refreshing (DoCmd.Echo False) open the form in edit mode (users won't see it), create and size your controls, save and close the form, open it again in normal mode, stop the hourglass and enable the screen refreshing (so that users see the final result).
This is perfectly feasable (I have done the same to allow users to customize a few reports features at run-time) although it may be slow.

Other alternatives may be:
- Using a continuous form if you don't mind having the result displayed on several lines
- Using the FlexGrid OCX control. I personally never used it so I cannot give first hand info but was said it is a convenient control for timetables.
 
Last edited:
Here's a simple, if somewhat crude timeline on a continuous form
 
Last edited:
Thanks for the code!
Just one little problem here: after adapting it to my table layout (timeline is spread over one day) I get:

=(LPad("I";" ";(DateDiff("s";[txtMinStartDate];[Start])/60)) & RPad("I";"I";(DateDiff("s";[Start];[Stop])/60)))

But when viewing the form it leaves me with "#Name?" although both [Start] and [Stop] have a valid value ("09:45" and "21:30") with notation resitriction (short time) and the txtMinStartDate and txtMaxEndDate are filled in with the same values...
I checked the DateDiff results and they are ok...

What am I doing wrong?
The example project works perfectly...
 
Thanks again, didn't notice that, thought they were predefined functions :rolleyes:

Works like a charm btw, you've been a great help :cool:
 
It was a Friday night, nothing on the TV, bored, fed up with decorating, I was going to go to the pub, I just decided to play with Access instead, as you do:)
 

Users who are viewing this thread

Back
Top Bottom