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 7077555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:26:16+00:00 2026-05-28T06:26:16+00:00

I have a query in access and I need it to also have an

  • 0

I have a query in access and I need it to also have an auto incremented field. I can’t add it physically to the table. I tried to create a function to the filed inc : incfun(1)

EDIT:
In my saved query I created a column in design mode called INC : incfun(1) <–This is how I call my function. It outputs the data to the INC column.

Here is my function in module1 script file.

Dim inc As Integer
Option Compare Database

Function incfun(num As Integer) '1 is first passed to function as 1
inc = num + 1 '1 added to global variable inc
incfun = inc  'inc value passed back to output of function.
End Function

EDIT: Every time I refresh the datasheet it goes up by 1, but doesn’t auto increment threw out all the rows. Anyway to make this work?

  • 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-28T06:26:16+00:00Added an answer on May 28, 2026 at 6:26 am

    Are you doing something like this?

    inc = incfun(1)
    inc = incfun(1)
    

    Both of these calls sets inc equal to the parameter (value = 1) + 1. No matter how many times you call it inc = incfun(1) will always set inc to 2.

    Either use inc = inc + 1 which I would have thought was the easier solution.

    or replace the body of the function with:

    inc = inc + n
    incfun = inc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL query (MS Access) and I need to add two columns,
I have an access database, with a query made. I need to automate it
In my SQL query in Access 2000, I have a field containing numbers like:
I have a table in Access with 1 field called HostName, it is a
I have an access query which creates some output, 3 columns named e.g. A
I have a Maketable query in an Access db that could use an Autonumber
I have a ASP.Net page using ADO to query MS access database and as
I have a Microsoft Access database query that I'm trying to import into a
I have the following Access 2002 query I'm running through OLE DB in .NET:
In MS Access Database Insert query to insert the character------> N'tetarnyl I have an

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.