I am working on a database for order quoting. There are times I need to insert a new line between two other lines. The line numbers need to be resequences when I do as in the original quote has line 1,2,3 I need to add a line between lines 2 and 3 making the new line 2 and the old line 2 needs to become 3 and line 3 will become line 4.
the code I currently have doing does now work with access 2007 I am not sure why....I get a message the the record is read only. the code is attached to a button click
thanks for any help
Mary
Private Sub InsertBtn_Click()
Dim rst As Recordset
Dim lngSeq As Long
On Error GoTo Errortrap
DoCmd.RunCommand acCmdSaveRecord
Set rst = Me!QuoteDetFrm01.Form.RecordsetClone
rst.MoveLast
If rst.EOF Then
lngSeq = 1
Else
lngSeq = Forms!QuoteFrm01!QuoteDetFrm01![QuoteDetTbl.Seq]
Do Until rst![QuoteDetTbl.Seq] < lngSeq
rst.Edit
rst![QuoteDetTbl.Seq] = rst![QuoteDetTbl.Seq] + 1
rst.Update
rst.MovePrevious
If rst.BOF Then Exit Do
Loop
End If
rst.Close
DoCmd.OpenForm "QuoteDetFrm03", , , , acFormAdd
Forms!QuoteDetFrm03!QuoteId = Me!QuoteId
Forms!QuoteDetFrm03!Seq = lngSeq
Exit Sub
the code I currently have doing does now work with access 2007 I am not sure why....I get a message the the record is read only. the code is attached to a button click
thanks for any help
Mary
Private Sub InsertBtn_Click()
Dim rst As Recordset
Dim lngSeq As Long
On Error GoTo Errortrap
DoCmd.RunCommand acCmdSaveRecord
Set rst = Me!QuoteDetFrm01.Form.RecordsetClone
rst.MoveLast
If rst.EOF Then
lngSeq = 1
Else
lngSeq = Forms!QuoteFrm01!QuoteDetFrm01![QuoteDetTbl.Seq]
Do Until rst![QuoteDetTbl.Seq] < lngSeq
rst.Edit
rst![QuoteDetTbl.Seq] = rst![QuoteDetTbl.Seq] + 1
rst.Update
rst.MovePrevious
If rst.BOF Then Exit Do
Loop
End If
rst.Close
DoCmd.OpenForm "QuoteDetFrm03", , , , acFormAdd
Forms!QuoteDetFrm03!QuoteId = Me!QuoteId
Forms!QuoteDetFrm03!Seq = lngSeq
Exit Sub