Navigation bar
  Home Print document Start Previous page
 148 of 234 
Next page End  

Gravitybox Schedule Primer
Page 146 
1998-2004 Gravitybox Software LLC
End Sub
The Print menu item will tell the active form to print itself. Every child knows how to print
itself as well.
Private Sub mnuFilePrint_Click()
  
  If MsgBox("Do you wish to print the active schedule?", _
         vbYesNo + vbQuestion, "Print?") = vbYes Then
    Call Me.ActiveForm.PrintFile
End If
 
End Sub
In order to prompt the user for dates we will need to construct a form for this action. We
only need to create a form with a textbox and two command buttons. The textbox will be
used to type in the date and the command buttons will be the “Ok” and “Cancel”
buttons. In the Ok button’s code we will need to check that the entered date is valid with
the VBA “IsDate” function. To ensure that we do not load a date twice we will need to
check the loaded child forms and verify that their dates are different than the target
date. The IsDateLoaded method is on the MDI parent form and is used for this purpose.
Private Function IsDateLoaded(ByVal dtDate As Date) As Boolean
Dim F As Form
  For Each F In Forms
    If F.Name = "frmChild" Then
      If F.MyDate = dtDate Then
        IsDateLoaded = True
        GoTo EndSub
      End If
    End If
  Next
  
EndSub:
End Function
'This function will ensure that the Date has no round-off error
Public Function GetDate(ByVal dtDate As Date) As Date
  GetDate = DateSerial(Year(dtDate), _
                       Month(dtDate), Day(dtDate))
End Function
http://www.purepage.com