1 / 7

Active-X Calendar Control

Active-X Calendar Control. Code to set dates. Private Sub Form_Open(Cancel As Integer) ' set button caption when form opens cmdSetDate.Caption = "Set beginning date“ End Sub. Private Sub cmdSetDate_Click() If cmdSetDate.Caption = "Set beginning date" Then

katina
Download Presentation

Active-X Calendar Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Active-X Calendar Control

  2. Code to set dates Private Sub Form_Open(Cancel As Integer) ' set button caption when form opens cmdSetDate.Caption = "Set beginning date“ End Sub Private Sub cmdSetDate_Click() If cmdSetDate.Caption = "Set beginning date" Then txtBeginDate = calSelectDate.Value cmdSetDate.Caption = "Set ending date" Else txtEndDate = calSelectDate.Value cmdSetDate.Caption = "Set beginning date" End If End Sub

  3. Code to preview report Private Sub cmdPrev_Click() Dim strRptName As String strRptName = "rptOrders" DoCmd.OpenReport strRptName, acViewPreview End Sub

  4. Check for valid date entry ' check that end date is > begin date If txtEndDate < txtBeginDate Then MsgBox "The ending date must be later than the beginning date" cmdSetDate.Caption = "Set ending date" calSelectDate.SetFocus Exit Sub End If ' check that value entered for begin date If IsNull(txtBeginDate) Then MsgBox "You must enter a beginning date" cmdSetDate.Caption = "Set beginning date" calSelectDate.SetFocus Exit Sub End If ' check that value entered for end date If IsNull(txtEndDate) Then MsgBox "You must enter an ending date" cmdSetDate.Caption = "Set ending date" calSelectDate.SetFocus Exit Sub End If Include this code in Click Event handler for Preview and Print Buttons

  5. Report No Data Event Private Sub Report_NoData(Cancel As Integer) Cancel = MsgBox("No orders to display in range specified. Cancelling report...", _ vbInformation, _ Me.Caption) End Sub

  6. Check whether form is open before running report Private Sub Report_Open(Cancel As Integer) IfNot FormIsloaded("frmPrintOrders") Then Cancel = MsgBox("To preview or print this report you need to select dates from the Print Orders form. Open form?", vbOKCancel, Me.Caption) If Cancel = vbOK Then DoCmd.OpenForm "frmPrintOrders" End If End If End Sub

  7. FormIsLoaded function Public Function FormIsloaded(strFrmName As String) As Boolean Const conFormDesign = 0 Dim intI As Integer FormIsloaded = False For intI = 0 To Forms.Count - 1 If Forms(intI).FormName = strFrmName Then If Forms(intI).CurrentView <> conFormDesign Then FormIsloaded = True Exit Function End If End If Next End Function

More Related