AutoNumber Row

saman

Registered User.
Local time
Today, 00:33
Joined
Dec 30, 2006
Messages
32
Hi all,
in the frmA has text box "AutRow" that add autonumber for every row.

Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
 Dim tmp As Variant
tmp = DMax("AutRow", "table1", "")
 If IsNull(tmp) Then
 tmp = 1
 Else
tmp = tmp + 1
End If
 Me!AutRow = tmp
End Sub

My problem is below:
If Me.Exm.value=Not isnull (or>0) then Add autonumber with AutRow But If Me.Exm.value= isnull (or zero) then do not Add every nomber with AutRow
thank
 

Attachments

I'm not sure I understood your problem, and I'm also not sure why you're not just using the built-in AutoNumber data type, but give this a shot:

Code:
Private Sub Form_BeforeInsert(Cancel As Integer)

    Dim tmp As Long
    tmp = DMax("AutRow", "table1", "")
    tmp = Switch(Nz(tmp,"")="",tmp,True,tmp + 1)
    Me!AutRow = tmp

End Sub
 

Users who are viewing this thread

Back
Top Bottom