Results 1 to 5 of 5
  1. #1
    KillGorack is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2022
    Posts
    13

    Angry Programmatically adding objects like lines

    Hi,

    I'm creating a one-off timeline that is comprised of some lines, and labels.

    This is being created in a report within a group header/

    Problem is, there are a lot of them, I'm creating a weekly calendar and I need ONE line and ONE label per week. Two years worth is over 100 of each of these.

    What I'm doing now is creating ALL of these lines and labels with names sticking those names in an array, and looping through some dates to position them. (Works pretty well) but it's a bit much.

    Create ALL the lines and create an array. (it's big)


    lineObjects = array("lnA", "lnB".......

    Same with the labels.

    Then I loop through dates, and position the lines and labels.
    Code:
        curDate = fromDate
        c = 0
        Do While curDate <= toDate
            yPitch = DateDiff("d", fromDate, curDate)
            Me.Controls(lineObjects(c)).Left = (dayPitch * yPitch)
            Me.Controls(labelObjects(c)).Left = (dayPitch * yPitch) + 10
            Me.Controls(labelObjects(c)).Caption = Format(DatePart("ww", curDate, vbMonday, vbFirstFourDays), "00")
            curDate = curDate + 7
            c = c + 1
        Loop
    Is there an easier way?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    not sure it helps but have you heard of the report lines feature? Or are you using the line object?

    https://learn.microsoft.com/en-us/of...ss.Report.Line

    You really need to provide a screenshot of the report so responders have a clear image of the requirement. From your description it is quite possible all you need is one label and one line in a continuous report and some code in the detail onformat event to reposition (I can't see how you could have 104 columns (given the max width of a report is around 560mm, means each column is about 5mm wide)

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Depending how you have the those lists of names, if in a separated string you could use the Split() function but probably easier is to add then to tables then use the GetRows method of a DAO.Recordset object to populate your arrays.
    https://learn.microsoft.com/en-us/of...ows-method-dao
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You may get some additional insight from this Draw Lines and Boxes article by Crystal.
    She has several articles - many great references.

  5. #5
    KillGorack is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2022
    Posts
    13
    I'm gonna try the report.lines thing for sure.. before we do image of the work in progress, and current code that moves the stuff around.
    Attached Thumbnails Attached Thumbnails Capture.jpg  

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Adding new objects Network error
    By nick243 in forum Access
    Replies: 17
    Last Post: 11-06-2017, 01:24 PM
  2. Get CPUID programmatically
    By mroshdy in forum Programming
    Replies: 4
    Last Post: 05-21-2017, 11:37 PM
  3. Replies: 17
    Last Post: 06-25-2013, 05:06 PM
  4. Replies: 3
    Last Post: 11-15-2012, 09:20 PM
  5. How to Programmatically Press a Key
    By Osman in forum Access
    Replies: 5
    Last Post: 11-28-2010, 11:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums