I have a procedure that does a query & creates a table from it. That part works fine. I am trying to run a 2nd query. However when I run it I get:
'
'"Run-Time error '2342'
' A RunSQL action requires an argument consisting
' of an SQL statement.
this occurs on the DoCmd.RunSQL getSchedChannel line.
I have tried using different runsql's but no matter how I set up the select, it bombs on the 2nd occurrence. (the sql's were cut & pasted directly from the access query builder so format shouldn't be the problem)
Any guidance would be appreciated. Thanks![[blush] [blush] [blush]](/data/assets/smilies/blush.gif)
The code is:
Private Sub Command1_Click()
Dim SQL As String
'
SQL = "SELECT DISTINCT [Channel Type].ChnlTypeId, ChannelName.ChannelName, Unit.UnitName, ScheduleHours.Day, ScheduleHours.Hour " & _
"INTO MonthlySchedule FROM [Channel Type] " & _
"INNER JOIN ((ScheduleHours INNER JOIN Unit ON ScheduleHours.UnitID = Unit.UnitID) " & _
"INNER JOIN ChannelName ON ScheduleHours.ChannelID = ChannelName.ChnlKey) " & _
"ON [Channel Type].ChnlTypeId = ChannelName.ChannelType"
DoCmd.RunSQL SQL
Dim dbsSATSCP As Database
Dim tdfMonthlySchedule As TableDef
Dim fldLoop As Field
' CodeDb refers to the database where code is running
Set dbs = CodeDb
Set tdfMonthlySchedule = dbs.TableDefs!MonthlySchedule
' Add new field
AppendDeleteField tdfMonthlySchedule, "APPEND", _
"ColorCd", dbLong
Dim getSchedChannel As String
'Here's where it gets stuck
getSchedChannel = "SELECT DISTINCT [Channel Type].ChnlTypeId, ChannelName.ChannelName " & _
"FROM [Channel Type] INNER JOIN (ScheduleHours INNER JOIN " & _
"ChannelName ON ScheduleHours.ChannelID=ChannelName.ChnlKey) ON " & _
"[Channel Type].ChnlTypeId=ChannelName.ChannelType"
DoCmd.RunSQL getSchedChannel
' Results in a :
'"Run-Time error '2342'
' A RunSQL action requires an argument consisting
' of an SQL statement.
End Sub
'
'"Run-Time error '2342'
' A RunSQL action requires an argument consisting
' of an SQL statement.
this occurs on the DoCmd.RunSQL getSchedChannel line.
I have tried using different runsql's but no matter how I set up the select, it bombs on the 2nd occurrence. (the sql's were cut & pasted directly from the access query builder so format shouldn't be the problem)
Any guidance would be appreciated. Thanks
![[blush] [blush] [blush]](/data/assets/smilies/blush.gif)
The code is:
Private Sub Command1_Click()
Dim SQL As String
'
SQL = "SELECT DISTINCT [Channel Type].ChnlTypeId, ChannelName.ChannelName, Unit.UnitName, ScheduleHours.Day, ScheduleHours.Hour " & _
"INTO MonthlySchedule FROM [Channel Type] " & _
"INNER JOIN ((ScheduleHours INNER JOIN Unit ON ScheduleHours.UnitID = Unit.UnitID) " & _
"INNER JOIN ChannelName ON ScheduleHours.ChannelID = ChannelName.ChnlKey) " & _
"ON [Channel Type].ChnlTypeId = ChannelName.ChannelType"
DoCmd.RunSQL SQL
Dim dbsSATSCP As Database
Dim tdfMonthlySchedule As TableDef
Dim fldLoop As Field
' CodeDb refers to the database where code is running
Set dbs = CodeDb
Set tdfMonthlySchedule = dbs.TableDefs!MonthlySchedule
' Add new field
AppendDeleteField tdfMonthlySchedule, "APPEND", _
"ColorCd", dbLong
Dim getSchedChannel As String
'Here's where it gets stuck
getSchedChannel = "SELECT DISTINCT [Channel Type].ChnlTypeId, ChannelName.ChannelName " & _
"FROM [Channel Type] INNER JOIN (ScheduleHours INNER JOIN " & _
"ChannelName ON ScheduleHours.ChannelID=ChannelName.ChnlKey) ON " & _
"[Channel Type].ChnlTypeId=ChannelName.ChannelType"
DoCmd.RunSQL getSchedChannel
' Results in a :
'"Run-Time error '2342'
' A RunSQL action requires an argument consisting
' of an SQL statement.
End Sub