| |

VerySource

 Forgot password?
 Register
Search
Author: cosila

What should I do if the ID field number is automatically +1 when adding a new record?

[Copy link]

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-28 16:00:01
| Show all posts
DataSet11.Tables("Application Form").Select("","ID Desc").GetValue(0).Item("ID") + 1
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-18 14:00:01
| Show all posts
Select("","ID Desc") What's in the first double quote here, please help me, thank you!
Newbie
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-19 19:45:01
| Show all posts
Back upstairs, it should be to write some simple expressions to narrow the scope of looking for ROW, just like writing the where statement after the SQL statement. For example, DataSet11.Tables("application form").Select("ID = '111' And name ='AAA'"), the row set should be found.
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-20 10:15:01
| Show all posts
Create a new table to store the current largest id,
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 United States

Post time: 2020-7-20 17:15:01
| Show all posts
This is a practical project we just learned. ID is C followed by three digits. You can follow the following pattern to form the code you need, I hope it will help you. This table is arranged by ID number.
Dim custid, custidval As String
        dt = DataSet11.Tables("CustomerTracking")'Assign the tables in the data set to dt
        len = dt.Rows.Count-1'dt.row.count represents the number of rows in the dt table
        dr = dt.Rows(len)'Give the last row of the dt table to dr
        custid = dr("CustID")'Give the "CustID" in dr to custid
        custidval = Mid(custid, 2, 3)'Go to the last three digits
        ctr = CInt(custidval)'Convert to a numeric value and remove the leading 0
        If ctr >= 1 And ctr <9 Then
            ctr = ctr + 1
            txtcustid.Text = "C00"&ctr
        ElseIf ctr >= 9 And ctr <99 Then
            ctr = ctr + 1
            txtcustid.Text = "C0"&ctr
        ElseIf ctr >= 99 And ctr <999 Then
            ctr = ctr + 1
            txtcustid.Text = "C"&ctr
        End If
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-20 18:15:01
| Show all posts
Back upstairs, your method is just to find the ID, there is no cleverness, it is just a display problem.
3Qlondy00's reply.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list