尝试编译时出错

时间:2015-06-16 19:33:57

标签: ms-access

我收到编译错误:

Sub or function not defined(粗体错误区域)

选项比较数据库 选项明确

Private Sub cboDates_AfterUpdate() On Error Resume 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)

End Sub Private Sub cboReportGroup_AfterUpdate() On Error GoTo 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

End Sub Private Sub cmdEndDate_Click() On Error Resume Next '启动日历控件

DateCheck_MEI Me.txtEndDate
Me.cboDates = Null

End Sub Private Sub cmdExport_Click() 错误GoTo 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:     Echo True     MsgBox Err.Description     恢复Err_Trap_Exit

End Sub Private Sub cmdOpen_Click() 错误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

End Sub Private Sub cmdStartDate_Click() On Error Resume Next '启动日历控件     DateCheck_MEI Me.txtStartDate     Me.cboDates = Null

End Sub Private Sub Form_Load()     调用cboReportGroup_AfterUpdate 结束子 Private Sub lstReport_Click() On Error Resume Next

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 = True     其他         Me.box1.Visible = False     结束如果

End Sub Private Sub lstReport_DblClick(取消为整数)     调用cmdOpen_Click 结束子

1 个答案:

答案 0 :(得分:0)

根据你发布的内容,忽略你的潜艇内部可能出现的错误,

修复将结束子:

Private Sub cmdStartDate_Click()
'Do stuff
End Sub 'This is the part you are missing