Autonumber Form?

jbphoenix

Registered User.
Local time
Today, 11:44
Joined
Jan 25, 2007
Messages
98
I have a form with the default view being datasheet. It's basically an order form. It's actually a subform linked to the main form by RMA_ID. So the user can enter multiple lines for the order. I need it to keep track of the Line Number. Is there a way to autonumber a field on a form so that each time the user enters another line item the count increases by 1? Right now the user has to manually enter the line number each time a line is added. I've attached a screenshot of the form.
 

Attachments

This may not be the best way to do it, but it seems to work when I was testing it.

I have a table "Friends" with name, phone, ItemNo

Code:
Private Sub Form_AfterInsert()
    
    Dim rs As Recordset
    Dim sSQL As String
    
    sSQL = ""
    sSQL = sSQL & "SELECT COUNT(*) FROM Friends "
    
    Set rs = CurrentDb.OpenRecordset(sSQL)
    
    If rs.EOF = False Then
        Me.ItemNo = rs(0)
    End If
    
    rs.Close
    Set rs = Nothing
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom