I need the code below to
-find the crm_nbr and revision number on a form
-then increment revision number by 1 -
-adding a whole row of fields to the table with the new revision number so that new copied record can be updated on the form and the old record kept as is.
Private Sub RevisionNumber()
Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim count As Integer
Set rs = Currentdb.OpenRecordset("SELECT CRM_NBR FROM tblCorpRMR19_1 WHERE CRM_NBR ='" & Me.cmbCRM & "'")
Set db = Currentdb
count = 0
If rs.RecordCount <> 0 Then
rs.MoveFirst
Do Until rs.EOF
count = count + 1
rs.MoveNext
Loop
Me!revision = count + 1 >> works fine to here and updates the form with the new revision number but need the old record saved to the table first and then the revision number added or keep the old row and add a new row with the new revision number........
rs.AddNew
'Me.Requery
Forms("frms19_1").Form![revision] = Me![revision]
Else
Forms("frms19_1").Form![revision] = Me![revision]
Me!revision = 1
rs.AddNew
On Error Resume Next
rs.Edit
rs("revision") = Me!revision
rs.update
End If
rs.Close
Set rs = Nothing
Set db = Nothing
-find the crm_nbr and revision number on a form
-then increment revision number by 1 -
-adding a whole row of fields to the table with the new revision number so that new copied record can be updated on the form and the old record kept as is.
Private Sub RevisionNumber()
Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim count As Integer
Set rs = Currentdb.OpenRecordset("SELECT CRM_NBR FROM tblCorpRMR19_1 WHERE CRM_NBR ='" & Me.cmbCRM & "'")
Set db = Currentdb
count = 0
If rs.RecordCount <> 0 Then
rs.MoveFirst
Do Until rs.EOF
count = count + 1
rs.MoveNext
Loop
Me!revision = count + 1 >> works fine to here and updates the form with the new revision number but need the old record saved to the table first and then the revision number added or keep the old row and add a new row with the new revision number........
rs.AddNew
'Me.Requery
Forms("frms19_1").Form![revision] = Me![revision]
Else
Forms("frms19_1").Form![revision] = Me![revision]
Me!revision = 1
rs.AddNew
On Error Resume Next
rs.Edit
rs("revision") = Me!revision
rs.update
End If
rs.Close
Set rs = Nothing
Set db = Nothing