Run time error '5': while using global variables


Run time error '5': while using global variables



i declared the global variable in the Module1 and when i was trying to use it in another module it is showing the runtime error '5':invalid procedure call or argument. i was unable to find the problem please provied the solution for this problem
Declaring global variable:


Function getFilePath() As String
getFilePath = FilePath
Set FilePath = "C:quadysterR3AgreementDetails"
End Function



Implementing of globalvariable:


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



this is the calling function


Public Function AttachR3ServiceAgreement(FilePath As String, tripData As
tripDetails, requestType As String)



Here error is occured:
Set objStream = objFSO.OpenTextFile(fileHTML, ForReading)





If it's a global why pass it as a parameter to your function? Or is it a different variable you're using as a global - Not very clear problem description
– dbmitch
Jul 1 at 16:48




1 Answer
1



You have a syntax error there: Set can only be used with objects.


Set


Public FilePath As String
Function getFilePath() As String
FilePath = "C:quadysterR3AgreementDetails"
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





I modify the code but the problem is stil there
– malavika
Jun 27 at 8:21





i inistalised the value for global variable in the function getFilePath() but while using the global variable it showing as empty string .
– malavika
Jun 27 at 8:30






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy