Need to edge out the competition for your dream job? Train for certifications today.
Public Function ReadSql()
Dim dbs As Database
Dim qdf As QueryDef
Dim intFileDesc As Integer 'File descriptor for output file
Dim strSourceFile As String 'Full path of source file
Dim strTextLine As String 'Input buffer
Dim strSQL As String
Set dbs = CurrentDb
strSourceFile = "c:\test\test.sql"
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
strSQL = strSQL & strTextLine & vbCrLf
Close #intFileDesc 'Close file.
On Error Resume Next
Set qdf = dbs.QueryDefs("tmpQdf")
If Err.Number <> 0 Then
Set qdf = dbs.CreateQueryDef("tmpQdf")
qdf.Sql = strSQL
Set qdf = Nothing
Set dbs = Nothing 'Garbage handling before we exit the function
Open in new window
Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.
(I assume that is what the sql file is for).
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.