我在报告中写了这些代码。
Option Compare Database
Option Explicit
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
Cancel = -1 '/*If no data cancel report*/
End Sub
Private Sub Report_Close() '/*To close Date dialog form which was hide after report opened*/
DoCmd.Close acForm, "Report Date Range"
End Sub
Sub Report_Open(Cancel As Integer) '/*To open Date dialog form*/
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "Select Report Date"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub
此代码在.accdb格式下工作正常但在我将数据库保存为.accde
格式时不起作用。实际上,它没有打开日期对话框表单,但它显示一个对话框“输入参数值”。请帮我解决这个问题。
我在预览按钮日期对话框中编写了以下代码。
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub
Private Sub Preview_Click()
If IsNull([Beginning Date]) Or IsNull([Ending Date]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToControl "Beginning Date"
Else
If [Beginning Date] > [Ending Date] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "Beginning Date"
Else
Me.Visible = False
End If
End If
End Sub
并且查询具有根据日期对话框表单中的给定日期过滤报告的条件。
“> = [表格]![报告日期范围]![开始日期]和<= [表格]![报告日期范围]![结束日期]”
我从某些形式中删除空子。现在工作正常。
例如:
Option Compare Database
Private Sub Previous_Product_Click()
End Sub