Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:14:12+00:00 2026-05-29T05:14:12+00:00

When a user completes a form, s/he can complete up to 5 records at

  • 0

When a user completes a form, s/he can complete up to 5 records at a time.

If the the user completes 1 record, the ID increments by 1.

However, when a user completes more than 1 record, we would expect the ID to increment by as many records as the user completed.

For instance, let’s say user with ID 2516 completes 3 records, we would expect to see something like:

ID    User
1      2516
2      2516
3      2516

If another user by id of 4874 completes 2, we would be:

ID    User           
 4    4874
 5    4874

etc

In stead, the value of ID is incrementing by only 1 no matter how many new records one particular user enters.

I know this is based on the code below.

Can you please help me fix it in such that the value increments based on how many records a particular user submits.

We don’t want to use identity seed to increment it.

Your help, as usual, is highly appreciated.

sql += "INSERT INTO Emp (UserSequence, employee_id, charity_code, check_amt, chcknum, one_time, bi_weekly, cash, donate_choice, date_stamp) "
                sql += "VALUES ((select isNull(max(UserSequence), 0) + 1, '" & Replace(employee_idLabel.Text, "'", "''") & "','" & Replace(dedval.SelectedValue, "'", "''") & "','" & Replace(chckval.Text, "'", "''") & "','" & Replace(chcknumval.Text, "'", "''") & "','" & Replace(onetimeval.Text, "'", "''") & "','" & multival.Text & "','" & Replace(cashval, "'", "''") & "','" & Replace(donatechoice.SelectedItem.Value, "'", "''") & "','" & Replace(datestamp, "'", "''") & "');"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:14:13+00:00Added an answer on May 29, 2026 at 5:14 am

    well this is rather your business logic.
    I would recommend you the followin structure

    create table myTable (
        int UserId not null,
        int myTableId int identity(1,1) primary key,
        int UserSequence int not null
    )
    

    and do insert statements like this.

    insert into myTable (UserId, UserSequence) values 
    (10, (select isNull(max(UserSequence), 0) + 1 from myTable where UserId=10))
    

    It does exactly what you need. You leave your primary key as is but add another column that serves for your business logic.

    EDIT

    By the way, your VB.Code looks very cumbersome.

    1. Dont use string concatinations. It is unsafe. (Best case exception about wrong sql, worst case sql injection)
    2. Just take a look at some ORM. That will greatly handle a lot of sql burden for you. Personally I suggest you Entity Framework.

    With ORM your code would look something like this.

    Dim dc As New MyDatabaseContext
    Dim records = dc.Recors.Where(Function(x) x.UserId = 10)
    Dim last as Integer = 0
    If records.Count > 0 Then last = records.Max(Function(x) x.UserSequence)
    Dim instance As New Record With {
        .UserId = 10,
        .UserSequence = last + 1
    }
    dc.Records.Add(instance)
    dc.SaveChanges()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I am looking to do is if a user complete a form it
I have working script that the user completes inputs on a form and when
I have an upload form that takes a user about 30 min. to complete.
I have a simple form where a user can add, edit, and delete people
I have a form with multiple fields, and each time the user changes a
I have a series of forms that I need a user to complete in
When the user starts typing in a combobox, auto-complete kicks in and shows the
User equals untrustworthy. Never trust untrustworthy user's input. I get that. However, I am
User registration in my application is performed in steps. After submitting the form, some
I have a large web form application that I want to allow the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.