Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14

    textbox Arry

    Hi everyone. I have a textbox Array forming a Calendar on a Form. how can I make the textbox which indicate to the current date change its background color
    with my appreciation.
    Attached Files Attached Files
    Last edited by ghiasibrahim; 06-19-2018 at 12:34 AM.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    you don't provide much info, so my suggestion would be conditional formatting, but you'd have to create the expression for every textbox, looking for its value to be Date().
    Otherwise, a code solution can work, but again, not telling us about the form means I don't even know if you have any code behind it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14
    thank you dear Micron. Conditional formatting did not work cause the textboxes show in addition to the day of date for example(23) other information brought out from a Sql (like name and number) for appointment in this day for example (johan 2) so it will look like 23 and in the next line blew Johan 2. conditional formatting works when there is no additional information to the day of date in the textbox. like just (23) and here is the code of the Array I have

    private sub intarray()


    Dim i As Integer


    ReDim myArray(0 To 41, 0 To 2)


    For i = 0 To 41


    myArray(i, 0) = lngFirstDayOfMonth - intFirstWeekday + 1 + i
    If Month(myArray(i, 0)) = intMonth Then
    myArray(i, 1) = True
    myArray(i, 2) = Day(myArray(i, 0))
    Else
    myArray(i, 1) = False

    End If
    Next i


    End Sub


    Private Sub LoadArray()


    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rsFiltered As DAO.Recordset
    Dim strSQL As String
    Dim i As Integer


    strSQL = "SELECT * FROM (SELECT `التاريخ حقل`,'مكرر الجلسات' AS `Type`,`مكرر الجلسات` FROM `استعلام الجلسات` UNION SELECT `التاريخ حقل`,'مكرر الأعمال ' AS `Type`, `مكرر الأعمال ` FROM `استعلام الأعمال الادارية`) AS AllSpecialDays ORDER BY 'التاريخ حقل';"


    Set db = CurrentDb
    Set rs = db.OpenRecordset(strSQL)

    If Not rs.BOF And Not rs.EOF Then

    For i = LBound(myArray) To UBound(myArray)

    If myArray(i, 1) Then
    rs.Filter = "[التاريخ حقل]=" & myArray(i, 0)

    Set rsFiltered = rs.OpenRecordset

    Do While (Not rsFiltered.EOF)

    myArray(i, 2) = myArray(i, 2) & vbNewLine _
    & rsFiltered![مكرر الجلسات]

    rsFiltered.MoveNext
    Loop

    End If
    Next i

    End If

    rsFiltered.Close
    rs.Close


    Set rsFiltered = Nothing
    Set rs = Nothing
    Set db = Nothing




    End Sub

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I agree with micron that you haven't provided much info.
    You could watch this free video for one approach to making a calendar.

    Good luck.

  5. #5
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14
    thank you so much I appreciate it, but I'have already did add the needed information

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Hard for me to exactly follow the sequence of events. I can look into old db's I have to see how I highlighted the current date for a custom calendar. Or you could post a zipped copy of your db. Maybe somewhere in your code a test for the array value behind equal to the day, and set that textbox background. Probably what I did but it has been a few years since then.

  7. #7
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14
    OK. I will, thank you Dear Micron

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Or you could post a zipped copy of your db.
    Whoops. Now I see that you did that already. Will take a look at what you posted.

  9. #9
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14
    thank you for your time and help

  10. #10
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    There is a problem with your posted db because you removed the code for the procedure LoadArray, thus the form won't open without raising an error.
    Can try copying from your post, but I can't be certain it's correct.
    EDIT - while there is code missing, it appears to be a system locale problem. My pc doesn't jive with what appears to be your Syrian Arabic locale settings. Thought I'd switch mine and give it a try. Hope it doesn't mess things up for me.
    EDIT 2 - there is also one or more missing tables as the sql statement can't find them. I will have to give up on your db and look for my past approach to a custom calendar.
    Last edited by Micron; 06-18-2018 at 07:15 PM. Reason: added info

  11. #11
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    try adding the red line to your PrintArray procedure. Note - you would have to modify the DatePart function to suit your locale settings, mainly whatever it is you consider to be the first day of the week. See https://www.techonthenet.com/access/...e/datepart.php

    You may also have to tweak the line due to the array(s) lower boundary being 0 instead of 1. When I ran it, the 15th was highlighted (today is the 18th here), so try it with your regional settings first, then alter the expression to shift the calculated result accordingly. An example of this follows the code.
    Code:
    Private Sub PrintArray()
    On Error GoTo ErrorHandler
    
    Dim strCtlName As String
    Dim i As Integer
    
    For i = LBound(myArray) To UBound(myArray)
        strCtlName = "txt" & CStr(i + 1)
        Controls(strCtlName).Tag = i
        Controls(strCtlName) = ""
        Controls(strCtlName) = myArray(i, 2)
        If i = DatePart("d", Date) Then Controls(strCtlName).BackColor = vbYellow
    Next i
    
    ExitSub:
        Exit Sub
    ErrorHandler:
        MsgBox "There has been an error. Please reload the form"
        Resume ExitSub
    
    End Sub
    If i = DatePart("d", Date)-3 Then Controls(strCtlName).BackColor = vbYellow : this should shift the highlighted control by 3; presumably in the right direction.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14
    You are completely right, but this Code managed to change the back color of textbox according to its number in the Array, which is the day of the current in our case not the current date itself. So when you navigate to the next month on calendar you'll find the same text box is still yellow indicating to another date.
    note." I have problem to uploading zipped file to the forum and the site denies to upload my zipped file, and I can't send file bigger than 500K any way" I'll try to find out why I got this problem, in spite of that I even changed the zipping program and I use 64bit winzip.
    My best thanks

  13. #13
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    I don't understand what "the day of the current" means.

    Did you compact db before zipping? If yes and it's still over the limit when zipped you could remove unnecessary objects.

    However, it is a bit of a pain for me to switch to your locale. My system runs slowly and I'm unsure if it will cause me any problem later. Try explaining what's wrong with the solution since we might be close. Remember- I said you need to tweak the expression to get your correct result since your calendar runs in reverse to North American ones.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    ghiasibrahim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Location
    Damascus
    Posts
    14
    Sorry for my bad English I meant by "the day of the current" the "day of the current date". for example if today is 19/6/2018 so the number of the day is (19) and the code:
    If i = DatePart("d", Date) Then Controls(strCtlName).BackColor = vbYellow
    makes the textbox number (19) in the array change its color to yellow, not the textbox which shows the day of the current date, and by current date here I mean real current date which value is (19/6/2018) not just (19) which the textbox shows. cause this number I mean (19) will repeat in other textbox in other months and will get yellow color too. I hope I could be clear enough this time.
    Appreciating your kindness and time.
    with my thanks

  15. #15
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    The problem for me is that I can't read Arabic (sorry if that's not what it is) labels on your form, so I didn't know how to operate the calendar and didn't realize you could navigate through it.

    So the issue now is that the 19th will highlight (which is correct for 06/19) but if you switch to July, the 19th will highlight? Should there be no highlight for July when it is now June? Or is the highlight based on some other data and not the current day in the current month? I think altering the code to only highlight when the month = the current month is what you need, but I'm trying to clarify first.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-01-2018, 03:10 AM
  2. Replies: 5
    Last Post: 02-04-2017, 07:34 AM
  3. Replies: 2
    Last Post: 04-29-2016, 09:06 PM
  4. Replies: 2
    Last Post: 12-22-2015, 09:09 PM
  5. Replies: 2
    Last Post: 04-20-2013, 03:37 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