insert row
2 TopicsUsing a Sequence
Consider this table: CREATE TABLE [Events]( [EventID] [int] NULL, << Other columns >> and this Sequence: CREATE SEQUENCE [NewEventID] AS [int] START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 NO CACHE and this Stored Procedure; CREATE PROCEDURE [Insert_Event] << Parameters >> AS BEGIN INSERT INTO [Events] ( EventID, << Other fields >> ) VALUES ( NEXT VALUE FOR NewEventID, << Other fields >> ) END GO When I run this procedure, I get this error message: NEXT VALUE FOR function cannot be used if ROWCOUNT option has been set, or the query contains TOP or OFFSET. None of those conditions are true so why am I getting this error message?639Views0likes12CommentsCorrect formatting of Row parametr within a Worksheets Insert command
Just to show that I have set up wswkname correctly - Early in the sub the following code lines execute, in the 'initialisation' part of the sub, and the values work elsewhere perfectly well. Dim ws As Worksheet Dim wswkname As String Set ws = ActiveSheet wswkname = ws.Name I have read and understood the following example code - Worksheets(“Insert row”).Rows(“11:15”).Insert Shift:=xlShiftDown I,. though, want the literals 11 and 15 to be variables. I have assigned the necessary variables to two variables, which are named fxRI1 and fxRI2. Accordingly I wrote the following code Dim fxRI1 As Long Dim fxRI2 As Long fxRI1 = sLast_Row.Value + 3 fxRI2 = sLast_Row.Value + 4 ' sLast_Row.Value is a form value passed to the Sub Worksheets(wswkname).Rows(fxRI1:fxRI2).Insert Shift:=xlShiftDown This 'construct' would not compile though. Corrections please. Best regards Philip Bendigo, VictoriaSolved1.2KViews0likes1Comment