MS Access Calendar Stop displaying time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RockKandee
    New Member
    • Dec 2013
    • 89

    #16
    Now that code actually makes some sense to me :D

    The other code - I was like - huh - I have no idea what this says - I only know if I click the button - it works!

    I will get back to you later today after I have a chance to print.

    Comment

    • RockKandee
      New Member
      • Dec 2013
      • 89

      #17
      ADezii - Update - the original code prints without the start time when I print from the version you posted. I need to play with the order of my print commands to make it work on my calendar.

      I didn't get a chance to add the new code you posted yet. So I will work on that tonight and test tomorrow. Will let you know how it all works out.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #18
        There is actually another Option, RockKandee, show you not wish to manually change the Value of the Conditional Compilation Constant IncludeStartTim e, and that is to create a simple Prompt when the Calendar Form Opens askinig the User to include this Field or not. A little clumsy, but solves the problem quite readily.
        1. Create a Global/Public Variable in the Standard Calendar All Code Module, as in:
          Code:
          Public blnIncludeStartTime As Boolean
        2. Prompt the User in the Calendar Courses Open() Event and ask he/she if they wish to include Start Time in the Calendar Display.
          Code:
          Private Sub Form_Open(Cancel As Integer)
          On Error GoTo Err_Form_Open
          Dim dtmTodaysDate
          Dim strMsg As String
          Dim intResponse As Integer
          
          dtmTodaysDate = Now
          objCurrentDate.Month = Month(dtmTodaysDate)
          objCurrentDate.Year = Year(dtmTodaysDate)
          
          intResponse = MsgBox("Include [Start Time] in Calendar Display", vbQuestion + vbYesNo, "Start Time Prompt")
          
          blnIncludeStartTime = (intResponse = vbYes)
          
          PopulateCalendar
          
          Exit_Form_Open:
            Exit Sub
            
          Err_Form_Open:
            MsgBox Err.Description, vbExclamation, "Error in Form_Open()"
              Resume Exit_Form_Open
          End Sub
        3. Adjust Code in the PopulateCalenda r() Routine to reflect this change in Logic (Code Lines 2, 37, 46, 52).
          Code:
          '************************************** CODE INTENTIONALLY OMITTED **************************************
          If blnIncludeStartTime Then
            strSQL = "Select QCourseSchedule.Title, QCourseSchedule.[Start Date], QCourseSchedule.[End Date], " & _
              "QCourseSchedule.[Start Time] From QCourseSchedule Where QCourseSchedule.[Start Date] " & _
              "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
              " or QCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
              " or (QCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
              " and QCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
              " ORDER BY QCourseSchedule.[Start Time], " & _
              "QCourseSchedule.[Start Date], QCourseSchedule.[Title];"
          Else
            strSQL = "Select QCourseSchedule.Title, QCourseSchedule.[Start Date], QCourseSchedule.[End Date] " & _
              "From QCourseSchedule Where QCourseSchedule.[Start Date] " & _
              "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
              " or QCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
              " or (QCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
              " and QCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
              " ORDER BY QCourseSchedule.[Start Date], QCourseSchedule.[Title];"
          End If
          
          Set rstEvents = db.OpenRecordset(strSQL)    'Added 4/16/2008
          
          Do While Not rstEvents.EOF
            'CFB added 2-18-10
            lngFirstDateInRange = rstEvents![Start Date]      '<Substitute for [Start Date]>
            If lngFirstDateInRange < lngFirstOfMonth Then
            lngFirstDateInRange = lngFirstOfMonth
            End If
            lngLastDateInRange = rstEvents![End Date]         '<Substitute for [End Date]>
            If lngLastDateInRange > lngLastOfMonth Then
              lngLastDateInRange = lngLastOfMonth
            End If
            
            For lngEachDateInRange = lngFirstDateInRange To lngLastDateInRange
              bytEventDayOfMonth = (lngEachDateInRange - lngLastOfPreviousMonth)
              bytBlockCounter = bytEventDayOfMonth + bytBlankBlocksBefore
                If blnIncludeStartTime Then
                   If IsNull(rstEvents![Start Time]) Then        '<Substitute for [Start Time]>
                     strStartTime = ""
                   Else
                     strStartTime = Format$(rstEvents![Start Time], "h:mm AM/PM")       '<Substitute for [Start Time]>
                   End If
                End If
                                                        '<Substitute for [Title]>
                If astrCalendarBlocks(bytBlockCounter) = "" Then
                  If blnIncludeStartTime Then
                    astrCalendarBlocks(bytBlockCounter) = rstEvents![Title] & Space(1) & strStartTime
                  Else
                    astrCalendarBlocks(bytBlockCounter) = rstEvents![Title]
                  End If
                Else
                  If blnIncludeStartTime Then
                    astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
                                                          rstEvents![Title] & Space(1) & strStartTime
                  Else
                    astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
                                                          rstEvents![Title]
                  End If
                End If
            Next lngEachDateInRange
            '************************************** CODE INTENTIONALLY OMITTED **************************************

        Comment

        • RockKandee
          New Member
          • Dec 2013
          • 89

          #19
          I think I will work on that last one.

          I am having some issues right now. Prior to this post, I thought I had the printing all set. I use this calendar as a pop up. So my print command would switch to design view, change pop up to no, go to normal view, print, then change back to pop up. In testing - without actually printing - all seemed great - as in not errors - code working. I over looked the fact that when the form changes to not a pop up, it is no longer on the month I want to print so it only prints the current month.

          Mix my OOPS in with all this fancy new code you have provided and my head hurts.

          So I am working on all this and will let you know how it turns out.

          Off to get some aspirin. LOL

          As always - ADezii is a sweetheart :*

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #20
            If you are having problems with the newest Code, I can Upload the Demo to you. Just let me know.

            Comment

            • RockKandee
              New Member
              • Dec 2013
              • 89

              #21
              Your code isn't my trouble, I think I understand it. However, I reserve the right to change my mind ;)

              I think I need to figure out how to add - pop up yes/no - to your on open prompt.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #22
                The MsgBox() function is always pop-up Kandee. If you want a window you can switch away from then you need to design a form to handle that for you.

                Comment

                • RockKandee
                  New Member
                  • Dec 2013
                  • 89

                  #23
                  The message box being a pop up is fine. I need the calendar form to not be pop up when printing.

                  I need to get the calendar to:

                  1. Change pop up to No
                  2. Change Start Time to not display
                  3. Print selected month
                  4. Change start time to show
                  5. Change pop up to Yes

                  I think I have it, or it may be wishful thinking - lol
                  Hopefully I can test it today.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #24
                    The two form properties you need for that are .PopUp & .Modal.

                    The call to open the form can also use a parameter WindowMode. When passed as acDialog this will be like a pop-up window.

                    Comment

                    • RockKandee
                      New Member
                      • Dec 2013
                      • 89

                      #25
                      Hmmmm....In English??????? LOL

                      My attempts failed today, but I will keep trying.

                      I didn't like having the message box display as an on open form event. So I made it a button. I now have 4 buttons.

                      1 - chooses display of start time or not (provided by ADezii)

                      2 - changes pop up to no

                      3 - prints

                      4 - changes pop up to yes

                      2-4 are my original Print button broken into 3 parts.

                      So, I can now print if I use the buttons separately. So I am down to only needing one calendar. HURRAY!

                      I really appreciate all of the help.

                      Comment

                      • zmbd
                        Recognized Expert Moderator Expert
                        • Mar 2012
                        • 5501

                        #26
                        2 - changes pop up to no (...)
                        4 - changes pop up to yes
                        You could write the code here to check the state and toggle; thus you would only need one button
                        Code:
                        (>>>aircode<<<) (^_^)
                        Select case popupmode
                           case popupmode = yes
                              popupmode = no
                              cmdbuttoncaption = "popup set to no"
                           case popupmode = no
                              popupmode = yes
                              cmdbuttoncaption = "popup set to yes"
                        end select
                        Or instead of cmdbuttoncaptio n = "popup set to no" you could set or reset the icon.

                        Comment

                        • RockKandee
                          New Member
                          • Dec 2013
                          • 89

                          #27
                          That is a good idea. Thank you

                          Comment

                          Working...