我得到一個編譯錯誤:錯誤當試圖編譯
Sub or function not defined
(粗體出錯區)
選項比較數據庫 顯式的選項
私人小組cboDates_AfterUpdate() 上的錯誤恢復Next
Dim strInterval As String
Dim dblValue As Double
Dim datStartDate As Date
Dim datEndDate As Date
Dim WeekdayStsrt As Integer
WeekdayStsrt = 1 'Start day of week - 1=Sunday, 2=Monday, 3=Tuesday...
'根據組合框選擇設置開始日期和結束日期文本框 strInterval = Me.cboDates.Column(1) dblValue = Me.cboDates.Column(2)
Select Case strInterval
Case "d"
datStartDate = Date
datEndDate = Date
Case "ww"
datStartDate = Date - Weekday(Date) + WeekdayStsrt
datEndDate = datStartDate + 6
Case "m"
datStartDate = DateSerial(Year(Date), Month(Date) + dblValue, 1)
datEndDate = DateSerial(Year(Date), Month(Date) + dblValue + 1, 0)
dblValue = 0
Case "yyyy"
datStartDate = DateSerial(Year(Date), 1, 1)
datEndDate = DateSerial(Year(Date), 12, 31)
Case "YTD"
datStartDate = DateSerial(Year(Date), 1, 1)
datEndDate = Date
strInterval = "yyyy"
Case "All"
datStartDate = DateSerial(2000, 1, 1) 'Earliest Date of available data in system
datEndDate = DateSerial(Year(Date), 12, 31)
strInterval = "d"
End Select
Me.txtStartDate = DateAdd(strInterval, dblValue, datStartDate)
Me.txtEndDate = DateAdd(strInterval, dblValue, datEndDate)
結束子 基於報告組私人小組cboReportGroup_AfterUpdate() 對錯誤轉到Err_Trap 」過濾器列表框組合框選擇。
Dim SQL As String
Me.lstReport = Null
SQL = Me.lstReport.Tag
If Not Me.cboReportGroup = "(All)" Then
SQL = SQL & " WHERE ReportGroup='" & Me.cboReportGroup & "'"
End If
SQL = SQL & " ORDER BY tsysReports.ReportTitle;"
Me.lstReport.RowSource = SQL
Err_Trap_Exit: 退出小組
Err_Trap: MSGBOX Err.Description 恢復Err_Trap_Exit
結束子 私人小組cmdEndDate_Click() 上的錯誤繼續下一步 「啓動日曆控件
DateCheck_MEI Me.txtEndDate
Me.cboDates = Null
結束子 私人小組cmdExport_Click() 對錯誤轉到Err_Trap
Dim SQL As String
Echo False
Call cmdOpen_Click 'execute the button that opens the report for print preview
SQLEdit_MEI "ArrivalTimingTableQuery", Application.Reports(Me.lstReport).RecordSource
If Application.Reports(Me.lstReport).Filter = "" Then
SQL = "SELECT * FROM ArrivalTimingTableQuery "
Else
SQL = "SELECT * FROM ArrivalTimingTableQuery WHERE " & Application.Reports(Me.lstReport).Filter
End If
SQLEdit_MEI "qryTempExport", SQL
DoCmd.OutputTo acOutputQuery, "qryTempExport", acFormatXLS, CurrentProject.Path & "\temp.xls", True
DoCmd.Close acReport, Me.lstReport, acSaveNo
Echo True
Err_Trap_Exit: 退出小組
Err_Trap: 回聲真 MSGBOX Err.Description 恢復Err_Trap_Exit
結束子 Private Sub cmdOpen_Click() On Error GoTo Err_Trap
Dim strCriteria As String
If Me.txtEndDate < Me.txtStartDate Then
MsgBox "End Date cannot be prior to Start Date."
Exit Sub
End If
If IsNull(Me.lstReport) Then
MsgBox "Please select a report"
Exit Sub
End If
If Not Me.lstReport.Column(2) = "" Then
strCriteria = Me.cboField & " Between #" & Me.txtStartDate & "# And #" & Me.txtEndDate & "#"
End If
DoCmd.OpenReport Me.lstReport, acViewReport, , strCriteria
Err_Trap_Exit: 退出小組
Err_Trap: MSGBOX Err.Description 恢復Err_Trap_Exit
結束子 私人小組cmdStartDate_Click() 上的錯誤繼續下一步 「啓動日曆控件 DateCheck_MEI Me.txtStartDate Me。cboDates = NULL
末次 私人小組的Form_Load() 呼叫cboReportGroup_AfterUpdate 結束小組 私人小組lstReport_Click() 上的錯誤繼續下一步
Me.lblDescription.Caption = "Report Description: " & Me.lstReport.Column(3)
Me.cboField.RowSource = Me.lstReport.Column(2) 'Set to values of DateCriteria field of table tsysReports
Me.cboField = Me.cboField.ItemData(0) 'Select 1st item in combobox
「隱藏報告標準部分,如果沒有日期過濾器的選擇報告 如果Me.lstReport.Column(2)= 「」 那 Me.box1.Visible =真 否則 Me.box1.Visible =假 結束如果
末次 私人小組lstReport_DblClick(取消作爲整數) 呼叫cmdOpen_Click 結束小組
您可以發佈該程序中的所有代碼請。 – Newd
它已全部更新。謝謝。感謝您的幫助 –
這是錯誤來了! Private Sub cmdStartDate_Click() On Error Resume Next'啓動日曆控件DateCheck_MEI Me.txtStartDate Me.cboDates = Null End Sub –