M
mrsdee
I have a Sub that renumbers records to allow for record insertion
anywhere in the table. For some reason the code returns to the
returning procedure after executing the LOC DoCmd.RunSQL(strSQL). I
have tried moving the last LOC above the DoCmd stmts and it returns to
the caller without executing any of the DoCmd stmts.
Any ideas why this may be happening?
Public Sub reNumber()
Dim newCtrlNum As Integer, curRecCtrlNum As Integer, frm As Form,
strSQL As String
'save current control number prior to renumbering-do renumbering prior
to assignment
'of number to new rec to prevent incidence of duplicate ctrl nums
Set frm = Forms![Update Product Area Checklist]
curRecCtrlNum = frm![txtCtrlNbr]
strSQL = "UPDATE[Product Checklist] SET [Control Number] = [Control
Number] + 1 WHERE [Control Number] >= " & curRecCtrlNum
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
'assign number to new item
Me.txtCtrlNumber.Value = curRecCtrlNum
End Sub
Thanks!
anywhere in the table. For some reason the code returns to the
returning procedure after executing the LOC DoCmd.RunSQL(strSQL). I
have tried moving the last LOC above the DoCmd stmts and it returns to
the caller without executing any of the DoCmd stmts.
Any ideas why this may be happening?
Public Sub reNumber()
Dim newCtrlNum As Integer, curRecCtrlNum As Integer, frm As Form,
strSQL As String
'save current control number prior to renumbering-do renumbering prior
to assignment
'of number to new rec to prevent incidence of duplicate ctrl nums
Set frm = Forms![Update Product Area Checklist]
curRecCtrlNum = frm![txtCtrlNbr]
strSQL = "UPDATE[Product Checklist] SET [Control Number] = [Control
Number] + 1 WHERE [Control Number] >= " & curRecCtrlNum
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
'assign number to new item
Me.txtCtrlNumber.Value = curRecCtrlNum
End Sub
Thanks!