hidrau
asked on
error on vba access function, ByRef
Hello Guys,
I have two function, the first function ask the user to informa a file.txt and then pass the file to the second function that have to open the file.
But access is complaining about it with " incompatible argument byRef"
Please, take a look at my code:
Why? How to solve that?
Thanks
Alex
I have two function, the first function ask the user to informa a file.txt and then pass the file to the second function that have to open the file.
But access is complaining about it with " incompatible argument byRef"
Please, take a look at my code:
Private Sub Comando0_Click()
Dim Message, Title, Default, MyValue
If MsgBox("Deseja realmente rodar o script??", vbQuestion + vbYesNo, "Script") = vbYes Then
Message = "Informe o script" ' Set prompt.
Title = "Execução de Script SQL" ' Set title.
Default = "" ' Set default.
MyValue = InputBox(Message, Title, Default)
If Trim(MyValue) = "" Then
MsgBox "Script não informado, será pego o padrão da pasta!", vbOKOnly, "Execução de Script"
Else
If Dir(strSourceFile) = vbNullString Then
MsgBox "Não existe o arquivo de script na pasta padão!", vbOKOnly
Else
Call ReadSql(MyValue)
End If
End If
End If
End Sub
Public Function ReadSql(arq As String)
Dim intFileDesc As Integer 'File descriptor for output file
Dim strSourceFile As String 'Full path of source file
Dim strTextLine As String 'Input buffer
Set dbs = CurrentDb
If arq = "" Then
strSourceFile = "c:\access\script.sql"
Else
strSourceFile = arq
End If
If Dir(strSourceFile) = vbNullString Then
MsgBox "Não existe o arquivo de script na pasta padão!", vbOKOnly
End If
intFileDesc = FreeFile
Open strSourceFile For Input As #intFileDesc
Do While Not EOF(intFileDesc) ' Loop until end of file.
Line Input #intFileDesc, strTextLine ' Read line into buffer
CurrentDb.Execute strTextLine
Loop
Close #intFileDesc 'Close file.
Set qdf = Nothing
Set dbs = Nothing 'Garbage handling before we exit the function
End Function
Why? How to solve that?
Thanks
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you're welcome ~ happy to help
ASKER