【问题标题】:MS Access: Why wont my report display the proper heading?MS Access:为什么我的报告不显示正确的标题?
【发布时间】:2021-10-13 08:42:45
【问题描述】:

我有一个根据用户选择生成报告的表单。

应该说“已完成:(他们选择的选项)。”当我选择其中一个选项时,它会显示正确的标题,但如果我选择“在报告中包含所有培训”选项,它会给我一个错误,说“无效使用 null”,然后在我去调试时提出这个问题。

Private Sub Report_Load()
    Auto_Header0.Caption = "Completed: " + Me.OpenArgs
    
    
End Sub

表单本身的代码是这样的......

Option Compare Database

Private Sub bBackCompletedTrainings_Click()
DoCmd.OpenForm "fTrainingMENU", acNormal
End Sub

Private Sub Command4_Click()
' Generate the report based on the control settings in the form
If cbAllTraining = True Then
    DoCmd.OpenReport "rAllCompletedTraining", acViewReport, , ""
    
    
Else
    DoCmd.OpenReport "rAllCompletedTraining", acViewReport, , "TrainingID = " & Me.lbTrainingID, , Me.lbTrainingID.Column(1)
    
    
    

End If

End Sub

为什么会这样?如果您需要更多信息,请告诉我。

【问题讨论】:

  • 听起来Me.OpenArgs 为空。这个名字指的是什么?
  • 使用& 进行字符串连接。我从不将+ 与字符串一起使用,因为这显然是一个数学运算符。
  • @HackSlash 指的是用户选择的选择。 & 有效,但它只显示“已完成:”,然后什么也没有。我希望它说“已完成:全部”或类似的内容。
  • 您在哪里将列表框中的选定值传递给报告 Open Args?是Me.lbTrainingID.Column(1) 吗?因为我认为这没有你想要的价值。

标签: sql vba ms-access debugging


【解决方案1】:

如果你只是想让它工作而不试图查看导致问题的原因,那么使用;

= "Completed: " & Nz(Me.OpenArgs,"All")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多