Below code is in my DB file.
If I enter a card no in first record, for Others card no will be automatically comming.

but for the other "Test " I want to show the record no automatically.
I was coded below. but it's not working.
Pls help me.
Thank you.

Dim card As Long
Dim aNumber As Long
 
Private Sub CardNo_AfterUpdate()
    card = card + 1
End Sub

Private Sub CardNo_BeforeUpdate(Cancel As Integer)
    card = CardNo.Text    
End Sub

Private Sub CardNo_GotFocus()
    If CardNo.Text = "" Then
        CardNo.Text = card
    End If
End Sub

Private Sub test_AfterUpdate()
    aNumber = aNumber + 1
End Sub

Private Sub test_BeforeUpdate(Cancel As Integer)
    aNumber = test.Text
End Sub

Private Sub test_GotFocus()
    If test.Text = "" Then
        aNumber = 1
        test.Text = aNumber
    End If
End Sub

Recommended Answers

All 4 Replies

Usually the database supports incremental numbering natively. What database are you using?

I'm using MS Access

Every Data base can support auto numbering .......

can I know that for which database you connect to the system........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.