Question : Access Coding

Hi Experts,
I'm having a problem with my coding.  attach is the Address form that I'm working and having problem on it.  the default value for the Status is set to "M" which is the mailing.  when there is an existing mailing address and I enter a new address, then the existing mailing will be change to previous and the new one I just entered will be show as Mailing, this part works fine, however, when there is no existing mailing address instead there is a  existing Alternate address, when I enter a new address, of course the new address will automic show as Mailing but the existing Alternate address did not change to previous,  I need to make the existing Alternate address atuomic change to show previous in the status.  can anyone help?  below is my code.  thanks

Private Sub Form_AfterUpdate()
    Dim rs2 As Recordset
    Dim Criteria As String
   
    Dim rs As DAO.Recordset
    Dim type_M As Integer
    Dim type_A As Integer
   
    HoldAddrType = Me.ADRSTATUS
    HoldAddrCntField = Me.ADDRCNT
    Me.Requery
    Select Case HoldAddrType
    Case "M", "A"
        Set rs = Me.RecordsetClone
        rs.MoveLast
        rs.MoveFirst
        Do Until rs.EOF
             If rs!ADRSTATUS = HoldAddrType And rs!ADDRCNT <> HoldAddrCntField Then
                rs.Edit
                rs!ADRSTATUS = "P"
                rs!ADRUPDT = Now()
                rs!ADRUSR = Environ("User")
                rs.Update
            End If
            rs.MoveNext
        Loop
        Criteria = "Select * from qryAddrP where ADRRIN = '" & Me.ADRRIN & "'"
        Set rs = CurrentDb.OpenRecordset(Criteria, dbOpenDynaset, dbSeeChanges)
        If Not rs.EOF Then
            rs.MoveLast
            rs.MoveFirst
            Do Until rs.RecordCount < 4
                rs.Edit
                rs.Delete
                rs.MoveNext
            Loop
        End If
        Set rs = Nothing
End Select
    Me.Requery
1:

Attachments:
 
Address form
 

Answer : Access Coding

I don't think you need to EDIT before DELETE

    Do Until rs.RecordCount < 4
                rs.Edit '--- I don't think this is necessary ----
                rs.Delete
                rs.MoveNext
Scott C
Random Solutions  
 
programming4us programming4us