DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   MS Access and FileMaker Pro (http://www.daniweb.com/forums/forum128.html)
-   -   SQL moving data error (http://www.daniweb.com/forums/thread160235.html)

Swarv Dec 1st, 2008 7:10 am
SQL moving data error
 
Hi all,

I have this sql line (below) and where it works fine at the moment. But I have columns with 2 words i.e. opened by. I would like to add this colum to the statement below but everytime i try it errors. Do I have to reword the statement or use special quotes?

Thanks

Martin


SQLText = "INSERT INTO issues1 ([title], [time], [Opened], [staff], [status], [category], [comment]) SELECT title, time, Opened, staff, status, category, comment " & "FROM issues where (issues.id=" & Me.ID & ")"

timothybard Dec 1st, 2008 9:49 am
Re: SQL moving data error
 
Can you show us the statement that doesn't work? My first guess would be that you don't have brackets around each of the fields. I see you have brackets in the Insert INTO section of the SQL Statement, but not in the SELECT section of the statement.

Swarv Dec 1st, 2008 10:09 am
Re: SQL moving data error
 
The statement above does work. I would have thought that the below would work. All I would do is place the column names in quotes.

SQLText = "INSERT INTO issues1 ("title", "time", "Opened", "opened by", "staff", "status", "category", "comment", "assigned to") SELECT title, time, Opened, opened by, staff, status, category, comment , assigned to" & "FROM issues where (issues.id=" & Me.ID & ")"

timothybard Dec 1st, 2008 10:16 am
Re: SQL moving data error
 
Try this:

SQLText = "INSERT INTO issues1 ([title], [time], [Opened], [opened by], [staff], [status], [category], [comment], [assigned to]) SELECT [title], [time], [Opened], [opened by], [staff], [status], [category], [comment] , [assigned to]" & "FROM issues where (issues.id=" & Me.ID & ")"

Swarv Dec 1st, 2008 10:34 am
Re: SQL moving data error
 
thanks, I must have forgotton the later [ marks.

cheers


All times are GMT -4. The time now is 4:10 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC