By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

MS Access Calendar Stop displaying time

RockKandee
P: 89
Hi!

I am using Access 2013 with Windows 8

I am working with this calendar

http://http://bytes.com/topic/access...ccess-calendar

I would like to know if there is a quick way to stop the display of the time with this calendar.

I already took the long route to accomplish this so there is no need to spend time explaining unless there is a quick and easy route.

My goal is to easily switch back and forth.

Thank bunches - Have an Awesome week end.
Jan 25 '14 #1

✓ answered by ADezii

I do believe that I may have arrived at a viable solution. It is a little complicated and convoluted so I will not go into the Logic until you have a look at it and see if it is what you want. The Code basically strips the Time Component out of each Day Block prior to actually Printing the Form. Since each Day Block is not 'Bound', has no Control Source, this action has no appreciable effect other than appearance. As soon as you move off the Current Month, the original Time Components are restored to the Day Blocks. In any event:
  1. Extract the Database from the Zip File I am sending you.
  2. Open the Database.
  3. Navigate to December 2013.
  4. Click on the Click Me RockKandee Command Button in the upper left hand corner of the Form.
  5. Notice that all of the Times only have been removed from the Day Block Displays.
  6. Move off December 2013 and the Normal Display will again be restored.
  7. Good luck and let us know how you make out.

Share this Question
Share on Google+
26 Replies


ADezii
Expert 5K+
P: 8,616
  1. The displaying of the Date/Time is controlled in the Timer() Event of the CalendarCourses Form, namely:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Timer()
    2. Static lngCounter As Long
    3.  
    4. lngCounter = lngCounter + 1
    5.  
    6. Me.Caption = "Calendar Courses (" & Format$(Now(), "dddd - mmmm dd, yyyy hh:mm:ss AM/PM") & ")"
    7.  
    8. If lngCounter > 2147483000 Then lngCounter = 0
    9. End Sub
    10.  
  2. This Timer() Event is activated every Second as indicated by the TimerInterval (1000) Property which is in Milliseconds:
    Expand|Select|Wrap|Line Numbers
    1. TimerInterval       1000
  3. If you wish to eliminate this Event all together simply set the TimerInterval Property to a Value of 0 which effective disables it:
    Expand|Select|Wrap|Line Numbers
    1. TimerInterval          0
  4. Any other questions, feel free to ask.
Jan 25 '14 #2

RockKandee
P: 89
Oops!

I meant [start time] not the actual time.

When I print the calendar, I need the start time to NOT be included due to space limitations.

My apologies for not being clear.

Thank you for your help (no kisses for you - the wife gets too jealous - lol)
Jan 25 '14 #3

NeoPa
Expert Mod 15k+
P: 31,308
If you pop in the code that displays the start point I should be able to tell you what needs to change Kandee.
Jan 25 '14 #4

RockKandee
P: 89
This shows what all I changed to get the start time to not show. The original code is still there.

Expand|Select|Wrap|Line Numbers
  1. 'Private Function InsertEvent(strExistingText As String, strTitle As String, strStartTime As String)
  2. Private Function InsertEvent(strExistingText As String, strTitle As String)
  3.                         '>>>> Kandee - Changed for printing without times
  4. On Error GoTo Err_InsertEvent
  5.        'CFB added 2-18-10
  6.        'Inserts an Event Title & Time into a block's string, sorted by Date (and maybe later, Title)
  7.  
  8. Dim lngBlockTextLength As Long
  9. Dim fEventPositionFound As Boolean
  10. 'Dim lngExistingEventTime As Long  'Kandee turned off for printing
  11. Dim lngExistingEventTitle As Long
  12. Dim strExistingEvent As String
  13. 'Dim strExistingEventTime As String   'Kandee turned off for printing
  14. 'Dim strEventTime As String  'Kandee turned off for printing
  15. Dim strEvent As String
  16. Dim lngEventInsertionPosition As Long
  17. Dim lngEventPlaceholder As Long
  18. 'Dim lngTimePlaceholder As Long 'Kandee turned off for printing
  19. Dim lngNewLinePosition As Byte
  20.  
  21.   'strEventTime = Format(strStartTime, "h:mm AMT/PM")   'don't show seconds Kandee trned off for printing
  22.   'strEvent = strTitle & Space(1) & strEventTime      'Kandee changed to a space instead of new line
  23.   strEvent = strTitle      'Kandee changed for printing without time
  24.  
  25. If strExistingText = "" Then
  26.       InsertEvent = strEvent
  27. Else
  28.                                       'parse and sort on time & title
  29.   lngBlockTextLength = Len(strExistingText)
  30.   lngNewLinePosition = InStrRev(strExistingText, vbNewLine)
  31.  
  32.         '>>>>>>>>>>>>>'Kandee turned off for printing
  33.   'strExistingEventTime = Right(strExistingText, lngBlockTextLength - lngNewLinePosition)
  34.     'If strExistingEventTime < strEventTime Then
  35.      ' fEventPositionFound = True
  36.        'Debug.Print "strExistingEventTime < strEventTime" & " | " & strExistingEventTime & " | " & strEventTime
  37.      '   Debug.Print "*****************************"
  38.       '  Debug.Print strEvent
  39.    ' Else
  40.             '>>>>>>>>>>>>>>>>>>
  41.       Debug.Print "Else...End If Clause activated"
  42.       fEventPositionFound = False
  43.       Do Until fEventPositionFound
  44.         lngNewLinePosition = InStrRev(strExistingText, vbNewLine)
  45.  
  46.         strExistingEvent = Left(strExistingText, 1)
  47.         'strExistingEventTime = Right(strExistingText, 10)      'Kandee turned off for printing
  48.       Loop
  49.     End If
  50.       InsertEvent = strExistingText & vbNewLine & strEvent
  51.         fEventPositionFound = True
  52. 'End If     'Kandee turned off for printing
  53.  
  54. Exit_InsertEvent:
  55.   Exit Function
  56.  
  57. Err_InsertEvent:
  58.   MsgBox Err.Description, vbExclamation, "Error in InsertEvent()"
  59.   Call LogErrors(Err.Number, Err.Description, "frmCalendar", "InsertEvent() Function", "Called from PopulateCalendar()")
  60.     Resume Exit_InsertEvent
  61. End Function
  62. Private Sub PopulateYearListBox()
  63.      'Procedure added 01-25-08 CFB
  64.      'Sets the Year selection list box to a 24 year range, f
  65.      'This procedure has not been thoroughly tested and it will produce a runtime error if
  66.      'you go before BC or after Nov 9999
  67.      'To use it, call it at the end of the PopulateCalendar procedure
  68.  
  69. Dim intYear As Integer
  70. Dim intYearCounter As Integer
  71. Dim strRowSource As String
  72.  
  73.   intYear = objCurrentDate.Year
  74.   Me.cboYear = intYear
  75.  
  76.      'For intYearCounter = 2000 To 2050        'a 51 year, Absolute Range
  77. For intYearCounter = (intYear - 12) To (intYear + 12)        'a 25 year range
  78.   strRowSource = strRowSource & LTrim(Str(intYearCounter)) & ";"
  79. Next intYearCounter
  80.   'strRowSource = strRowSource & LTrim(str(intYearCounter))    'the XX year, no semi-colon
  81.   Me.cboYear.RowSource = Left$(strRowSource, Len(strRowSource) - 1)
  82. End Sub
  83. Private Sub OpenEventForm(ctlDayBlock As Control)
  84.   DoCmd.OpenForm "frmEvents", , , , , , ctlDayBlock.Tag
  85. End Sub
  86. Private Sub cboMonth_AfterUpdate()
  87. On Error GoTo Err_cboMonth_AfterUpdate
  88.  
  89. Select Case Me![cboMonth]
  90.   Case "January"
  91.     objCurrentDate.Month = 1
  92.   Case "February"
  93.     objCurrentDate.Month = 2
  94.   Case "March"
  95.     objCurrentDate.Month = 3
  96.   Case "April"
  97.     objCurrentDate.Month = 4
  98.   Case "May"
  99.     objCurrentDate.Month = 5
  100.   Case "June"
  101.     objCurrentDate.Month = 6
  102.   Case "July"
  103.     objCurrentDate.Month = 7
  104.   Case "August"
  105.     objCurrentDate.Month = 8
  106.   Case "September"
  107.     objCurrentDate.Month = 9
  108.   Case "October"
  109.     objCurrentDate.Month = 10
  110.   Case "November"
  111.     objCurrentDate.Month = 11
  112.   Case "December"
  113.     objCurrentDate.Month = 12
  114.   Case Else
  115. End Select
  116. PopulateCalendar
  117. Exit_cboMonth_AfterUpdate:
  118.   Exit Sub
  119.  
  120. Err_cboMonth_AfterUpdate:
  121.   MsgBox Err.Description, vbExclamation, "Error in cboMonth_AfterUpdate()"
  122.   Resume Exit_cboMonth_AfterUpdate
  123. End Sub
  124.  
  125. Private Sub cboYear_AfterUpdate()
  126.   objCurrentDate.Year = Me![cboYear]
  127.   PopulateCalendar
  128. End Sub
  129.  
  130. Private Sub cmdNextMonth_Click()
  131.    Me![cboYear] = Null
  132.    Me![cboMonth] = Null
  133.  
  134.    objCurrentDate.Month = objCurrentDate.Month + 1
  135. If objCurrentDate.Month = 13 Then
  136.   objCurrentDate.Month = 1
  137.   objCurrentDate.Year = objCurrentDate.Year + 1
  138. End If
  139.   PopulateCalendar
  140. End Sub
  141. Private Sub cmdPreviousMonth_Click()
  142.    Me![cboYear] = Null
  143.    Me![cboMonth] = Null
  144.  
  145.    objCurrentDate.Month = objCurrentDate.Month - 1
  146. If objCurrentDate.Month = 0 Then
  147.   objCurrentDate.Month = 12
  148.   objCurrentDate.Year = objCurrentDate.Year - 1
  149. End If
  150. PopulateCalendar
  151. End Sub
  152.  
  153.  
  154.  
  155. Private Sub ctrlPrint_Click()
  156.  
  157.  
  158. '*********Kandee added PRINT COMMANDS************
  159.  
  160.  'DoCmd.PrintOut Application.Printers("HP Deskjet 3050A J611 series (Copy 1)").Orientation = acPRORLandscape
  161.         ' prints all pages - code received from ADezii on Bytes thread
  162.  'DoCmd.RunCommand acCmdPrintPreview 'opens preview currently creates an error message
  163.  'DoCmd.RunCommand acCmdPrint 'opens page range
  164. 'Forms("CalendarAll").Printer.Orientation = acPRORLandscape
  165. 'DoCmd.PrintOut , 1, 1, acLow, 1, False 'prints only first page of form
  166.  
  167. '>>>>>>>change pop up to no then print only first page then back to pop up
  168.  DoCmd.OpenForm "CalendarPrint", acDesign
  169.      Forms!CalendarPrint.PopUp = False
  170.  DoCmd.Close acForm, "CalendarPrint", acSaveYes
  171.  DoCmd.OpenForm "CalendarPrint", acNormal
  172.    Forms("CalendarPrint").Printer.Orientation = acPRORLandscape
  173.  DoCmd.PrintOut , 1, 1, acLow, 1, False
  174.  DoCmd.OpenForm "CalendarPrint", acDesign
  175.   Forms!CalendarPrint.PopUp = True
  176.  DoCmd.Close acForm, "CalendarPrint", acSaveYes
  177.  DoCmd.OpenForm "CalendarPrint", acNormal
  178.  
  179. '****************************************************
  180.  
  181. End Sub
  182.  
  183. Private Sub Form_Activate()
  184.   PopulateCalendar
  185. End Sub
  186. Private Sub Form_Open(Cancel As Integer)
  187.  
  188. '>>>>>>>>>>>>KANDEE - Old Code - Multi Calendar Use<<<<<<<<<<<<
  189. 'DoCmd.RunSQL "DELETE tblCalendarAll.* FROM tblCalendarAll"
  190.  
  191. 'DoCmd.RunSQL "INSERT INTO tblCalendarAll ( [Start Date], [End Date], [Start Time], [End Time], [Title] )" & _
  192. '" SELECT DISTINCTROW qryCourseSchedule.[Start Date], qryCourseSchedule.[End Date]," & _
  193. '" qryCourseSchedule.[Start Time], qryCourseSchedule.[End Time], qryCourseSchedule.[Title]" & _
  194. '" FROM qryCourseSchedule"
  195.  
  196. 'DoCmd.RunSQL "INSERT INTO tblCalendarAll ( [Start Date], [End Date], [Start Time], [End Time], [Title] )" & _
  197. '" SELECT DISTINCTROW TCalendarHolidays.[Start Date], TCalendarHolidays.[End Date]," & _
  198. '" TCalendarHolidays.[Start Time], TCalendarHolidays.[End Time], TCalendarHolidays.[Title]" & _
  199. '" FROM TCalendarHolidays"
  200.  
  201. 'DoCmd.RunSQL "INSERT INTO tblCalendarAll ( [Start Date], [End Date], [Start Time], [End Time], [Title] )" & _
  202. '" SELECT DISTINCTROW TEventSchedule.[Start Date], TEventSchedule.[End Date]," & _
  203. '" TEventSchedule.[Start Time], TEventSchedule.[End Time], TEventSchedule.[Title]" & _
  204. '" FROM TEventSchedule"
  205. '>>>>>>>>>>>>>KANDEE add end<<<<<<<<<<<<<<<<<<<<<<<<<<<
  206.  
  207.  
  208. On Error GoTo Err_Form_Open
  209. Dim dtmTodaysDate
  210. Dim strMsg As String
  211.  
  212. dtmTodaysDate = Now
  213. objCurrentDate.Month = Month(dtmTodaysDate)
  214. objCurrentDate.Year = Year(dtmTodaysDate)
  215.  
  216. '>>>>>>Kandee added so calendar will populate using popup window<<<<<
  217. PopulateCalendar
  218. '>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<
  219.  
  220. Exit_Form_Open:
  221.   Exit Sub
  222.  
  223. Err_Form_Open:
  224.   MsgBox Err.Description, vbExclamation, "Error in Form_Open()"
  225.   Resume Exit_Form_Open
  226. End Sub
  227. Private Sub PopulateCalendar()
  228. On Error GoTo Err_PopulateCalendar
  229. Dim strFirstOfMonth As String, bytFirstWeekdayOfMonth As Byte, bytBlockCounter As Byte
  230. Dim bytBlockDayOfMonth As Byte, lngBlockDate As Long, ctlDayBlock As TextBox
  231. Dim bytDaysInMonth As Byte, bytEventDayOfMonth As Byte, lngFirstOfMonth As Long
  232. Dim lngLastOfMonth As Long, lngFirstOfNextMonth As Long, lngLastOfPreviousMonth As Long
  233. Dim lngEventDate As Long, bytBlankBlocksBefore As Byte, bytBlankBlocksAfter As Byte
  234. Dim astrCalendarBlocks(1 To 42) As String, db As DAO.Database, rstEvents As DAO.Recordset
  235. Dim strEvent As String
  236. Dim lngSystemDate As Long   'CFB added 1-25-08
  237. Dim ctlSystemDateBlock As TextBox, blnSystemDateIsShown As Boolean  'CFB added 1-25-08
  238. Dim strSQL As String        'Added 4/16/2008
  239. Dim lngFirstDateInRange As Long     'CFB added 2-18-10
  240. Dim lngLastDateInRange As Long      '
  241. Dim lngEachDateInRange As Long      '
  242. 'Dim strStartTime As String          ''Kandee turned off for printing
  243.  
  244. lngSystemDate = Date        'CFB added 1-25-08
  245. intMonth = objCurrentDate.Month
  246. intYear = objCurrentDate.Year
  247. lstEvents.Visible = False
  248. labelEventsOnDate.Visible = False
  249. labelMonth.Caption = MonthAndYear(intMonth, intYear)
  250. strFirstOfMonth = Str(intMonth) & "/1/" & Str(intYear)
  251.  
  252. '*************************************************************************
  253.   'ADezii
  254.   'NOTE: Will work in the UK (United Kingdom) and other European Nations
  255.   'strFirstOfMonth = "1/" & Str(intMonth) & Str(intYear)
  256.   'strFirstOfMonth = "1/" & Str(intMonth) & "/" & Str(intYear) ' Kandee - found this on Bytes thread PPelle added "/"
  257. '*************************************************************************
  258.  
  259.  
  260. '>>>>>>>>>>>>>>>>>>>>>>>>> START DAY OF WEEK <<<<<<<<<<<<<<<<<<<<<<<
  261. ' Kandee - turn on for Monday start week - turn off for Sunday start week - found this on Bytes thread -PPelle added vbMonday
  262. 'bytFirstWeekdayOfMonth = Weekday(strFirstOfMonth, vbMonday)
  263. 'Kandee - turn this off for Monday week start or on for Sunday week start
  264. bytFirstWeekdayOfMonth = Weekday(strFirstOfMonth)
  265. '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<
  266.  
  267. lngFirstOfMonth = DateSerial(intYear, intMonth, 1)
  268. lngFirstOfNextMonth = DateSerial(intYear, intMonth + 1, 1)
  269. lngLastOfMonth = lngFirstOfNextMonth - 1
  270. lngLastOfPreviousMonth = lngFirstOfMonth - 1
  271. bytDaysInMonth = lngFirstOfNextMonth - lngFirstOfMonth
  272. bytBlankBlocksBefore = bytFirstWeekdayOfMonth - 1
  273. bytBlankBlocksAfter = 42 - (bytBlankBlocksBefore + bytDaysInMonth)
  274.  
  275. Set db = CurrentDb
  276.  
  277.  
  278.            'CFB added 2-18-10
  279. '<<<<<<<<<<<<<<<Substitute your own SQL Statement here>>>>>>>>>>>>>>>
  280. strSQL = "Select qryCourseSchedule.Title, qryCourseSchedule.[Start Date], qryCourseSchedule.[End Date], " & _
  281.          "qryCourseSchedule.[Start Time] From qryCourseSchedule Where qryCourseSchedule.[Start Date] " & _
  282.          "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
  283.          " or qryCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
  284.          " or (qryCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
  285.          " and qryCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
  286.          " ORDER BY qryCourseSchedule.[Start Time], " & _
  287.          "qryCourseSchedule.[Start Date], qryCourseSchedule.[Title];"
  288. '<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  289.  
  290.  
  291. Set rstEvents = db.OpenRecordset(strSQL)    'Added 4/16/2008
  292.  
  293. Do While Not rstEvents.EOF
  294.                                          'CFB added 2-18-10
  295.   lngFirstDateInRange = rstEvents![Start Date]      '<Substitute for [Start Date]>
  296.   If lngFirstDateInRange < lngFirstOfMonth Then
  297.   lngFirstDateInRange = lngFirstOfMonth
  298.   End If
  299.   lngLastDateInRange = rstEvents![End Date]         '<Substitute for [End Date]>
  300.   If lngLastDateInRange > lngLastOfMonth Then
  301.     lngLastDateInRange = lngLastOfMonth
  302.   End If
  303.  
  304.   For lngEachDateInRange = lngFirstDateInRange To lngLastDateInRange
  305.     bytEventDayOfMonth = (lngEachDateInRange - lngLastOfPreviousMonth)
  306.     bytBlockCounter = bytEventDayOfMonth + bytBlankBlocksBefore
  307.      ' If IsNull(rstEvents![Start Time]) Then        '<Substitute for [Start Time]>  'Kandee turned off for printing
  308.        ' strStartTime = ""
  309.      ' Else   'Kandee turned off for printing
  310.  
  311.  
  312.      '**********************CHOOSE TIME FORMAT**********************
  313.  
  314.         'strStartTime = Format$(rstEvents![Start Time], "Short Time")       'Military Time <Substitute for [Start Time]>
  315.         'strStartTime = Format$(rstEvents![Start Time], "h:mm AM/PM")        '<Substitute for [Start Time]>
  316.                     'Kandee turned off for printing
  317.         '**********************************************************
  318.  
  319.  
  320.      ' End If       'Kandee turned off for printing
  321.                                               '<Substitute for [Title]>
  322.                           'Kandee's modified code - removed new line and replaced with a space
  323.       If astrCalendarBlocks(bytBlockCounter) = "" Then
  324.         'astrCalendarBlocks(bytBlockCounter) = rstEvents![Title] & Space(1) & strStartTime
  325.                                                                         'Kandee turned off for printing
  326.         astrCalendarBlocks(bytBlockCounter) = rstEvents![Title]
  327.  
  328.       Else                                    '<Substitute for [Title]>
  329.         astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
  330.                                               rstEvents![Title] '& Space(1) & strStartTime  'Kandee turned off for printing
  331.  
  332.  
Blows kisses to NeoPa
Jan 25 '14 #5

ADezii
Expert 5K+
P: 8,616
I do believe that you are over complicating the matter. Give the following a try then get back to us.
  1. Set the Orientation of the Application Printer to Landscape.
  2. Temporarily disable the Timer by setting the TimerInterval Property to 0.
  3. Temporarily change the Caption of the Calendar Form so that it does not display the Time but just Calendar Courses along with the Day and Date.
  4. Select the Current Record so that only the Current Calendar Display that you are looking at will print.
  5. Print the Selection.
  6. Reset the TimerInterval to 1000 (1 sec) to return to normal display with the Time.
    Expand|Select|Wrap|Line Numbers
    1. Application.Printer.Orientation = acPRORLandscape
    2.  
    3. With Me
    4.   .TimerInterval = 0
    5.   .Caption = "Calendar Courses (" & Format$(Now(), "dddd - mmmm dd,yyyy") & ")"
    6.      DoCmd.RunCommand acCmdSelectRecord
    7.      DoCmd.RunCommand acCmdPrintSelection
    8.   .TimerInterval = 1000
    9. End With
    10.  
  7. Let us know how you make out.
Jan 26 '14 #6

RockKandee
P: 89
I didn't actually try the code you provided, I just changed the code manually. I can't print for a couple of days, so I could only test by viewing. However, those changes only made the time in the form's caption go away.

Maybe it only works for printing and not viewing?

I need the [Start Time] that displays with the [Title] in each day block to not show.

Expand|Select|Wrap|Line Numbers
  1. 'Private Function InsertEvent(strExistingText As String, strTitle As String, strStartTime As String)
  2. Private Function InsertEvent(strExistingText As String, strTitle As String)
That's why I changed the string.

Thanks ADezii - smooches
Jan 26 '14 #7

ADezii
Expert 5K+
P: 8,616
I need the [Start Time] that displays with the [Title] in each day block to not show
To the best of my knowledge, this cannot be done unless you repopulate the Calendar eliminating the Start Time Element from each Day Block, then Print it.
Jan 26 '14 #8

RockKandee
P: 89
Ok - Keeping my separate printable version is what I will do.

Thank you!
Jan 26 '14 #9

ADezii
Expert 5K+
P: 8,616
I do believe that I may have arrived at a viable solution. It is a little complicated and convoluted so I will not go into the Logic until you have a look at it and see if it is what you want. The Code basically strips the Time Component out of each Day Block prior to actually Printing the Form. Since each Day Block is not 'Bound', has no Control Source, this action has no appreciable effect other than appearance. As soon as you move off the Current Month, the original Time Components are restored to the Day Blocks. In any event:
  1. Extract the Database from the Zip File I am sending you.
  2. Open the Database.
  3. Navigate to December 2013.
  4. Click on the Click Me RockKandee Command Button in the upper left hand corner of the Form.
  5. Notice that all of the Times only have been removed from the Day Block Displays.
  6. Move off December 2013 and the Normal Display will again be restored.
  7. Good luck and let us know how you make out.
Attached Files
File Type: zip RockKandee_4.zip (3.24 MB, 52 views)
Jan 27 '14 #10

NeoPa
Expert Mod 15k+
P: 31,308
When I asked for the code that printed the [Start Time] Kandee, that was all I wanted.

The whole module leaves me having to interpret what everything does before I can even start looking at the code in question. I'm not as familiar with the whole database as ADezii is.

If you can show just the relevant code I'll see what I can do for you. From ADezii's replies already though, I guess it may be somewhat more complicated than I would have expected. I'm happy to look though.
Jan 27 '14 #11

RockKandee
P: 89
ADezii is a Rock Star.

It looks perfect. I am at home and out of ink - lol. I will test the printing on Tuesday and let you know. Thank you so much.

NeoPa

That isn't the whole module it is only part of it. I copied from the first mention of [Start Time] through to the last mention. I do not know which parts print the start time. I think it prints simply because it is displayed on the form. I am not sure which parts of the code need to be removed in order for the display to stop. That's why I changed all of the parts in the above posted code. Cuz I don't know what I am doing :S

But thank you very much for the offer :D
Jan 27 '14 #12

ADezii
Expert 5K+
P: 8,616
Just wanted to mention that I see a reference to the InsertEvent() Function, namely:
Expand|Select|Wrap|Line Numbers
  1. Private Function InsertEvent(strExistingText As String, strTitle As String, strStartTime As String)
  2. 'Code intentionally omitted
  3. End Function
  4.  
This is a legacy Function that was to be integrated into the Access Calendar by the Original Author many years ago, but never was. It would have been called from the PopulateCalendar() Sub-Routine when Data was written to each of the Day Blocks. After taking over the DB I simply left it in tact (partially completed) in an attempt to maintain as much of the Legacy Code as possible. It serves no real purpose in the Calendar Database.
Jan 27 '14 #13

NeoPa
Expert Mod 15k+
P: 31,308
Fair enough Kandee :-)
Jan 28 '14 #14

ADezii
Expert 5K+
P: 8,616
After much thought, RockKandee, there is actually another approach that can resolve your dilemma and it involves the use of a Conditional Compilation Constant. Simply setting the Value of this Constant to True includes Start Time in the Day Blocks of the Calendar while False does not include it. Refer to Code Lines: 2, 4-21, 39-45, 48-52, and 54-60.
Expand|Select|Wrap|Line Numbers
  1. '************************************** CODE INTENTIONALLY OMITTED **************************************
  2. #Const IncludeStartTime = True
  3.  
  4. #If IncludeStartTime Then
  5.   strSQL = "Select QCourseSchedule.Title, QCourseSchedule.[Start Date], QCourseSchedule.[End Date], " & _
  6.     "QCourseSchedule.[Start Time] From QCourseSchedule Where QCourseSchedule.[Start Date] " & _
  7.     "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
  8.     " or QCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
  9.     " or (QCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
  10.     " and QCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
  11.     " ORDER BY QCourseSchedule.[Start Time], " & _
  12.     "QCourseSchedule.[Start Date], QCourseSchedule.[Title];"
  13. #Else
  14.   strSQL = "Select QCourseSchedule.Title, QCourseSchedule.[Start Date], QCourseSchedule.[End Date] " & _
  15.     "From QCourseSchedule Where QCourseSchedule.[Start Date] " & _
  16.     "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
  17.     " or QCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
  18.     " or (QCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
  19.     " and QCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
  20.     " ORDER BY QCourseSchedule.[Start Date], QCourseSchedule.[Title];"
  21. #End If
  22.  
  23. Set rstEvents = db.OpenRecordset(strSQL)    'Added 4/16/2008
  24.  
  25. Do While Not rstEvents.EOF
  26.   'CFB added 2-18-10
  27.   lngFirstDateInRange = rstEvents![Start Date]      '<Substitute for [Start Date]>
  28.   If lngFirstDateInRange < lngFirstOfMonth Then
  29.   lngFirstDateInRange = lngFirstOfMonth
  30.   End If
  31.   lngLastDateInRange = rstEvents![End Date]         '<Substitute for [End Date]>
  32.   If lngLastDateInRange > lngLastOfMonth Then
  33.     lngLastDateInRange = lngLastOfMonth
  34.   End If
  35.  
  36.   For lngEachDateInRange = lngFirstDateInRange To lngLastDateInRange
  37.     bytEventDayOfMonth = (lngEachDateInRange - lngLastOfPreviousMonth)
  38.     bytBlockCounter = bytEventDayOfMonth + bytBlankBlocksBefore
  39.       #If IncludeStartTime Then
  40.          If IsNull(rstEvents![Start Time]) Then        '<Substitute for [Start Time]>
  41.            strStartTime = ""
  42.          Else
  43.            strStartTime = Format$(rstEvents![Start Time], "h:mm AM/PM")       '<Substitute for [Start Time]>
  44.          End If
  45.       #End If
  46.                                               '<Substitute for [Title]>
  47.       If astrCalendarBlocks(bytBlockCounter) = "" Then
  48.         #If IncludeStartTime Then
  49.           astrCalendarBlocks(bytBlockCounter) = rstEvents![Title] & Space(1) & strStartTime
  50.         #Else
  51.           astrCalendarBlocks(bytBlockCounter) = rstEvents![Title]
  52.         #End If
  53.       Else
  54.         #If IncludeStartTime Then
  55.           astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
  56.                                                 rstEvents![Title] & Space(1) & strStartTime
  57.         #Else
  58.           astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
  59.                                                 rstEvents![Title]
  60.         #End If
  61.       End If
  62.   Next lngEachDateInRange
  63.   '************************************** CODE INTENTIONALLY OMITTED **************************************
P.S. - The Code may not be Optimized since I simply threw it together on a whim.
Jan 28 '14 #15

RockKandee
P: 89
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.
Jan 28 '14 #16

RockKandee
P: 89
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.
Jan 29 '14 #17

ADezii
Expert 5K+
P: 8,616
There is actually another Option, RockKandee, show you not wish to manually change the Value of the Conditional Compilation Constant IncludeStartTime, 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:
    Expand|Select|Wrap|Line Numbers
    1. 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.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. On Error GoTo Err_Form_Open
    3. Dim dtmTodaysDate
    4. Dim strMsg As String
    5. Dim intResponse As Integer
    6.  
    7. dtmTodaysDate = Now
    8. objCurrentDate.Month = Month(dtmTodaysDate)
    9. objCurrentDate.Year = Year(dtmTodaysDate)
    10.  
    11. intResponse = MsgBox("Include [Start Time] in Calendar Display", vbQuestion + vbYesNo, "Start Time Prompt")
    12.  
    13. blnIncludeStartTime = (intResponse = vbYes)
    14.  
    15. PopulateCalendar
    16.  
    17. Exit_Form_Open:
    18.   Exit Sub
    19.  
    20. Err_Form_Open:
    21.   MsgBox Err.Description, vbExclamation, "Error in Form_Open()"
    22.     Resume Exit_Form_Open
    23. End Sub
  3. Adjust Code in the PopulateCalendar() Routine to reflect this change in Logic (Code Lines 2, 37, 46, 52).
    Expand|Select|Wrap|Line Numbers
    1. '************************************** CODE INTENTIONALLY OMITTED **************************************
    2. If blnIncludeStartTime Then
    3.   strSQL = "Select QCourseSchedule.Title, QCourseSchedule.[Start Date], QCourseSchedule.[End Date], " & _
    4.     "QCourseSchedule.[Start Time] From QCourseSchedule Where QCourseSchedule.[Start Date] " & _
    5.     "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
    6.     " or QCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
    7.     " or (QCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
    8.     " and QCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
    9.     " ORDER BY QCourseSchedule.[Start Time], " & _
    10.     "QCourseSchedule.[Start Date], QCourseSchedule.[Title];"
    11. Else
    12.   strSQL = "Select QCourseSchedule.Title, QCourseSchedule.[Start Date], QCourseSchedule.[End Date] " & _
    13.     "From QCourseSchedule Where QCourseSchedule.[Start Date] " & _
    14.     "Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
    15.     " or QCourseSchedule.[End Date] Between " & lngFirstOfMonth & " And " & lngLastOfMonth & _
    16.     " or (QCourseSchedule.[Start Date] < " & lngFirstOfMonth & _
    17.     " and QCourseSchedule.[End Date] > " & lngLastOfMonth & ")" & _
    18.     " ORDER BY QCourseSchedule.[Start Date], QCourseSchedule.[Title];"
    19. End If
    20.  
    21. Set rstEvents = db.OpenRecordset(strSQL)    'Added 4/16/2008
    22.  
    23. Do While Not rstEvents.EOF
    24.   'CFB added 2-18-10
    25.   lngFirstDateInRange = rstEvents![Start Date]      '<Substitute for [Start Date]>
    26.   If lngFirstDateInRange < lngFirstOfMonth Then
    27.   lngFirstDateInRange = lngFirstOfMonth
    28.   End If
    29.   lngLastDateInRange = rstEvents![End Date]         '<Substitute for [End Date]>
    30.   If lngLastDateInRange > lngLastOfMonth Then
    31.     lngLastDateInRange = lngLastOfMonth
    32.   End If
    33.  
    34.   For lngEachDateInRange = lngFirstDateInRange To lngLastDateInRange
    35.     bytEventDayOfMonth = (lngEachDateInRange - lngLastOfPreviousMonth)
    36.     bytBlockCounter = bytEventDayOfMonth + bytBlankBlocksBefore
    37.       If blnIncludeStartTime Then
    38.          If IsNull(rstEvents![Start Time]) Then        '<Substitute for [Start Time]>
    39.            strStartTime = ""
    40.          Else
    41.            strStartTime = Format$(rstEvents![Start Time], "h:mm AM/PM")       '<Substitute for [Start Time]>
    42.          End If
    43.       End If
    44.                                               '<Substitute for [Title]>
    45.       If astrCalendarBlocks(bytBlockCounter) = "" Then
    46.         If blnIncludeStartTime Then
    47.           astrCalendarBlocks(bytBlockCounter) = rstEvents![Title] & Space(1) & strStartTime
    48.         Else
    49.           astrCalendarBlocks(bytBlockCounter) = rstEvents![Title]
    50.         End If
    51.       Else
    52.         If blnIncludeStartTime Then
    53.           astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
    54.                                                 rstEvents![Title] & Space(1) & strStartTime
    55.         Else
    56.           astrCalendarBlocks(bytBlockCounter) = astrCalendarBlocks(bytBlockCounter) & vbNewLine & _
    57.                                                 rstEvents![Title]
    58.         End If
    59.       End If
    60.   Next lngEachDateInRange
    61.   '************************************** CODE INTENTIONALLY OMITTED **************************************
    62.  
Jan 29 '14 #18

RockKandee
P: 89
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 :*
Jan 30 '14 #19

ADezii
Expert 5K+
P: 8,616
If you are having problems with the newest Code, I can Upload the Demo to you. Just let me know.
Jan 30 '14 #20

RockKandee
P: 89
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.
Jan 30 '14 #21

NeoPa
Expert Mod 15k+
P: 31,308
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.
Jan 30 '14 #22

RockKandee
P: 89
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.
Jan 30 '14 #23

NeoPa
Expert Mod 15k+
P: 31,308
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.
Jan 31 '14 #24

RockKandee
P: 89
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.
Jan 31 '14 #25

zmbd
Expert Mod 5K+
P: 5,332
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
Expand|Select|Wrap|Line Numbers
  1. (>>>aircode<<<) (^_^)
  2. Select case popupmode
  3.    case popupmode = yes
  4.       popupmode = no
  5.       cmdbuttoncaption = "popup set to no"
  6.    case popupmode = no
  7.       popupmode = yes
  8.       cmdbuttoncaption = "popup set to yes"
  9. end select
Or instead of cmdbuttoncaption = "popup set to no" you could set or reset the icon.
Jan 31 '14 #26

RockKandee
P: 89
That is a good idea. Thank you
Feb 1 '14 #27

Post your reply

Sign in to post your reply or Sign up for a free account.