Results 1 to 13 of 13
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365

    Transfer Dates To Each Text Box

    Hi Guy's hope you are all good, can anyone advise on how to get the correct results individually into each text box on this one please ?

    I guess it's like a calendar but more for booking usage

    so i have the following code and results, just need to somehow add the 1st record into txt1, 2nd record into txt2 etc etc until all records have filled to txt31 (when 31 days) or filled to txt30 when 30 days in selected month



    Code:
    dtStart = DMin("FullDate", "tblCalendar", "[DateYear] = " & intYear & " And [DateMonth] = " & intMonth)       
    dtEnd = DMax("FullDate", "tblCalendar", "[DateYear] = " & intYear & " And [DateMonth] = " & intMonth)
    
    
            i = 1
            d = dtStart
            Do While dtStart <= dtEnd
                    
                    strDays = Format(d, "dddd") & vbTab & Format(d, "d") & vbTab & Format(d, "mmmm") & vbTab & intYear
                    
                    d = DateAdd("d", 1, d)
                    
                    Debug.Print "Dates: " & strDays
                    
                    If d > dtEnd Then
                        Exit Do
                    End If
                    i = i + 1
            Loop
    Immediate window

    Code:
    Dates: Tuesday  1   July    2025
    Dates: Wednesday    2   July    2025
    Dates: Thursday 3   July    2025
    Dates: Friday   4   July    2025
    Dates: Saturday 5   July    2025
    Dates: Sunday   6   July    2025
    Dates: Monday   7   July    2025
    Dates: Tuesday  8   July    2025
    Dates: Wednesday    9   July    2025
    Dates: Thursday 10  July    2025
    Dates: Friday   11  July    2025
    Dates: Saturday 12  July    2025
    Dates: Sunday   13  July    2025
    Dates: Monday   14  July    2025
    Dates: Tuesday  15  July    2025
    Dates: Wednesday    16  July    2025
    Dates: Thursday 17  July    2025
    Dates: Friday   18  July    2025
    Dates: Saturday 19  July    2025
    Dates: Sunday   20  July    2025
    Dates: Monday   21  July    2025
    Dates: Tuesday  22  July    2025
    Dates: Wednesday    23  July    2025
    Dates: Thursday 24  July    2025
    Dates: Friday   25  July    2025
    Dates: Saturday 26  July    2025
    Dates: Sunday   27  July    2025
    Dates: Monday   28  July    2025
    Dates: Tuesday  29  July    2025
    Dates: Wednesday    30  July    2025
    Dates: Thursday 31  July    2025

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Name the controls txtDatex where x is 1 to 31, and then use that count of i to select the correct control.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Hi WGM, hope you are ok and coping with your type 2, my type 1 is up and down on the freestyle sensor, it's either sugar sweet to boost or nova rapid pen drop levels

    So a quick question, when you say name the controls, do mean 31 text boxes ? thinking each text box has to be uniquely named....

    Thanks again

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Yes, that is the way I have seen it done, so just the index changes. Makes coding easier.

    Google Peter Hibbs Calendar.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    just need to somehow add the 1st record into txt1, 2nd record into txt2 etc etc until all records have filled to txt31 (when 31 days) or filled to txt30 when 30 days in selected month
    If you're trying to slot up to 31 values into controls that represent dates like on a real calendar, you need 42, not 31? If the 1st falls on a Saturday, your calendar would have 6 rows of 7 days = 42 textboxes.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Sorry, I was thinking of Peter Hibbs Holiday Planner, but logic is the same.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Ahh thanks micron, i have had a quick look at Peter Hibbs as per WGM, i was generating a booking form but suppose it's like a calendar as such, but yes good point, many months have an over lap of days etc.........

    Thanks for input

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Or 28/29 days for February.

    And yes, if you want a monthly calendar display, wouldn't you need 35 textboxes - 5 rows of 7 days each (Sun - Sat)? At least, that's what I see in calendars.

    Then code needs to calculate which textbox to start with and it won't always be tbxDay1. This means starting index of loop would be variable.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    wouldn't you need 35 textboxes - 5 rows of 7 days each (Sun - Sat)? At least, that's what I see in calendars.
    Look at June 2024. A printed calendar will split the 29th and 30th (for that date) into one "cell" above the other in the 5th row. If you're doing this in a calendar type of form you really can't do that - at least not easily. So you end up with 6 rows. If a 31 day month starts on Friday, you only have room in the last row for 30 days, so again, you need 6 rows. While the first 5 in row one will be empty in that case, they are needed for other months, so in the grand scheme, 7 in a row, 6 rows required - 42 controls.

    I've done this before.
    Last edited by Micron; 12-18-2024 at 03:57 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Ah, good point. I see Mar, Aug, Nov in 2025 like that. As you said, "not easily" but 5 rows could be dealt with or just go with 6.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Design kinda looks like this
    Click image for larger version. 

Name:	CalendarDesign.jpg 
Views:	26 
Size:	65.0 KB 
ID:	52509

    Ignore any numbers (labels at top right corner of textboxes, where the input values go). Code determines the start/end points and hides what doesn't apply for a given month/year. Sometimes an entire top row isn't visible, sometimes the bottom, sometimes partial rows. Each textbox and label name ends with a number (0 based, 0 - 41). The arrow command buttons move 1 month or year up/down, the combos drop a list of months/years.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Here's an old app that I use to generate the textboxes and labels for calendars and a couple other things,
    Like Micron, I've done this before. Just generate the textboxes and cut and paste into your project.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  13. #13
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Thank you guy,s between you all, i will inspect code etc and try pick up your methods... kindest

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

Similar Threads

  1. Replies: 2
    Last Post: 09-19-2017, 11:31 AM
  2. Replies: 4
    Last Post: 02-19-2014, 03:32 PM
  3. Replies: 2
    Last Post: 11-22-2012, 05:21 PM
  4. Transfer Text to Unbound Form
    By DWS in forum Forms
    Replies: 3
    Last Post: 08-25-2009, 08:04 AM
  5. Transfer text
    By nshaikh in forum Import/Export Data
    Replies: 0
    Last Post: 09-11-2008, 03:27 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