Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date scale across top of form based on form data.

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
I am currently using MS Access 2003 but I have another computer with 2007. I would like to show the following on a form....using one or both of these versions.

I will have data on a form. One field will be a start date...another will be and end date. I would like to show a scale of dates across the top of the form that begins with the start date and ends with the end date (probably + a couple of days on either side).

Has anyone ever tryed (successfully) to do this? Something like this?

9/1/2013...|...9/2/2013...|...9/3/2013...|.........etc up to the end date.

Thanks,
 
How are ya puforee . . .

Agree with [blue]dhookom[/blue] as to the unbound textboxes. Then its a simple matter of enumerating from the start date to the end. However ... you do realize screen realestate will keep your [blue]textbox count[/blue] on the low side! (unless you intend to have more than one row)

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
If doing something like this I strongly suggest not to build your controls dynamically. It is better just to make the max feasible limit of controls

design view
1) Create X amount of textboxes or labels.
2) Use a common naming convention like txt1,txt2,...txt30
3) For real estate stack them all on top of each other
4) Set all applicable textboxes to invisible
Runtime
5) At some point determine how many text boxes you need based on some kind of input
6) determine the size of the available form
7) Use a loop to determine size your controls ((size of form - any buffer) / required number of control), move into position, unhide control, apply formatting, fill in the dates
or as stated use a standard size and make multiple rows.

Here is an example of placing, sizing, and showing a group of controls on a form. It appears to be dynamic, but the controls are just hidden and then the correct amount made visible.

Code:
Public Sub formatGrid(x As Long, y As Long)
  Const ctlWidth = (0.75 * 1440)
  Const ctlHeight = (0.25 * 1440)
  Const conStartLeft = (0.5 * 1440)
  Const conStartTop = (1 * 1440)
  
  Dim startLeft As Long
  Dim startTop As Long
  Dim lngRow As Long
  Dim lngCol As Long
  Dim intCounter As Long
  Dim ctl As Access.Control
  
  startLeft = conStartLeft
  startTop = conStartTop
  
  For lngRow = 1 To y
     For lngCol = 1 To x
     intCounter = intCounter + 1
     Set ctl = Me.Controls("lblGrid" & intCounter)
     With ctl
         .Height = ctlHeight
         .Width = ctlWidth
         .Left = startLeft
         .Top = startTop
         .Caption = "Row" & lngRow & " Col" & lngCol
         .FontSize = 8
         .Visible = True
         .Tag = lngRow & ";" & lngCol
         'Define the function here that they do when clicked.
         .OnClick = "=gridClick()"
       End With
       startLeft = startLeft + ctlWidth
     Next lngCol
     startLeft = conStartLeft
     startTop = startTop + ctl.Height
  Next lngRow
 
 End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top