View Full Version : Error 3027


iknowu99
09-18-2008, 10:28 AM
Hello Everybody!
This the code i'm testing out. It will not let me run the last line. Error 3027: Cannot update. Database or object is read-only. Help:)

Option Compare Database
Option Explicit


Sub test12()
'----------------------
Dim sSQL As String
Dim sFileType As String
Dim sDestPath As String
Dim sExt As String
Dim sTableQuery As String
Dim dbFailOnError
Dim DB As Database
Set DB = CurrentDb

'sFileType = "Text;"
'sExt = "txt"
sFileType = "HTML Export;"
sExt = "htm"
sDestPath = "C:\TEMP\"
sTableQuery = "Master_DB Query1"

sSQL = "SELECT * INTO [" & sFileType & _
"DATABASE=" & sDestPath & "].[FileName" & _
sExt & "] " & "FROM [" & sTableQuery & "]"

DB.Execute sSQL, dbFailOnError

'-------------
End Sub

WayneRyan
09-18-2008, 12:32 PM
99,

Here's what your SQL translates to:


sSQL = "SELECT * INTO [HTML Export;DATABASE=C:\TEMP\].[FileNametxt] FROM [Master_DB Query1]"

I don't think your database path/name is what you really want.

To assist in debugging:

Put --> MsgBox sSQL

Wayne

iknowu99
09-18-2008, 12:36 PM
I dont know the syntax>... what should it be??

Guus2005
09-18-2008, 12:36 PM
Try to execute the query from de QBE.
Retrieve the SQL string like this:

Put a breakpoint on this lineDB.Execute sSQL, dbFailOnError

Run the code and when it stop on this line, copy the querystring to the immediate window,
?sSQLand copy the result into the QBE. Now run it.

iknowu99
09-18-2008, 12:38 PM
guys i know a bit about VBA from Excel >> i've been F8'ing this one for awhile but it still has the error?? what syntax is right for the SQL statment? i want it to save into the Temp directory for now.

Guus2005
09-18-2008, 12:58 PM
Here's an example:
SELECT tblCD.rubriek, tblCD.id, Month([datum]) AS Maand INTO OtherTable IN 'C:\Temp\db2.mdb' FROM tblCD;

or fill in the properties of the query.

Enjoy!