ms-access - 运行时错误“5”:使用全局变量时
问题描述
我在 Module1 中声明了全局变量,当我尝试在另一个模块中使用它时,它显示运行时错误“5”:\无效的过程调用或参数。我无法找到问题请提供此问题的解决方案声明全局变量:
Function getFilePath() As String
getFilePath = FilePath
Set FilePath = "C:\quadyster\R3AgreementDetails"
End Function
全局变量的实现:
Private Sub SendAgreement_Click()
If (Not IsNull(Me.RequestFrom) And Not IsNull(Me.RequestReference)) Then
Call AttachR3ServiceAgreement(Module1.FilePath, tripObjectFormation, "Agreement")
Me.AgreementDate = Now()
Else
MsgBox "Please provide 'RequestFrom' and 'RequestReference' to proceed." & vbNewLine & vbNewLine & _
"Press Ok to continue.", vbOKOnly, "Alert!!!"
End If
End Sub
这是调用函数
Public Function AttachR3ServiceAgreement(FilePath As String, tripData As
tripDetails, requestType As String)
这里发生错误: Set objStream = objFSO.OpenTextFile(fileHTML, ForReading)
解决方案
你有一个语法错误:Set
只能与对象一起使用。
Public FilePath As String
Function getFilePath() As String
FilePath = "C:\quadyster\R3AgreementDetails"
getFilePath = FilePath
End Function
Private Sub SendAgreement_Click()
If (Not IsNull(Me.RequestFrom) And Not IsNull(Me.RequestReference)) Then
Call AttachR3ServiceAgreement(Module1.FilePath, tripObjectFormation, "Agreement")
Me.AgreementDate = Now()
Else
MsgBox "Please provide 'RequestFrom' and 'RequestReference' to proceed." & vbNewLine & vbNewLine & _
"Press Ok to continue.", vbOKOnly, "Alert!!!"
End If
End Sub
推荐阅读
- python - 设计一个正则表达式以排除带有反斜杠的字符串部分
- swift - swift - 快速显示上下文菜单时如何自定义预览
- excel - Excel根据单元格VBA自动更改工作表名称
- javascript - 使用 react.js 加载数组
- python - 当数据集包含超过 50000 个缺失值时,如何使用 pandas 在数据分析中处理缺失的分类数据?
- regex - 无法找出以下的正则表达式
- python - 在 AWS Lambda (Python) 中将文件从 multipart/form-data 上传到 S3
- python - 加密整行文本
- arrays - 持有一个排序数组 - 反向排序的输入案例
- azure - 从 csv 文件中删除用户的 Azure 许可证