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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:22:15+00:00 2026-06-11T19:22:15+00:00

I am using an MS Access append query to append inventory transactions to my

  • 0

I am using an MS Access append query to append inventory transactions to my ERP database (MYSQL).
Please advise how I would go about to modify my query to automatically insert the next sequential transaction ID (primary key) into the Inventory_transaction table, with ability to append multiple records at once.

My existing query works fine, but only when I append just one record.
I usually need to append multiple records simultaneously. Each record needs to have a unique sequential transaction ID (primary key). There would be multiple users using this app simultaneously, so I need minimal chance of duplicate a key violation, to prevent roll backs. I tried appending without using a primary key to see if my database would automatically assign a transaction ID, but unfortunately this this ERP field is not an auto-number and I cant modify the table structure…

Below are 2 queries.
This one currently works for generating a transaction ID for just one record.

SELECT Max([SYSADM_INVENTORY_TRANS].[TRANSACTION_ID])+1 AS new_inventory_transaction_ID
FROM SYSADM_INVENTORY_TRANS;

The 2nd query is the append query that contains the first query and I would much appreciate it if someone can modify the query so the user has ability to append multiple records at once with a unique transaction ID.

INSERT INTO SYSADM_INVENTORY_TRANS ( TRANSACTION_ID, WORKORDER_TYPE,
  WORKORDER_BASE_ID, WORKORDER_LOT_ID, WORKORDER_SPLIT_ID, WORKORDER_SUB_ID,
  OPERATION_SEQ_NO, REQ_PIECE_NO, PART_ID, TYPE, CLASS, QTY, COSTED_QTY,
  TRANSACTION_DATE, WAREHOUSE_ID, LOCATION_ID, USER_ID, POSTING_CANDIDATE,
  ACT_MATERIAL_COST, ACT_LABOR_COST, ACT_BURDEN_COST, ACT_SERVICE_COST,
  CREATE_DATE, ADD_BURDEN, COUNT_SEQUENCE, DESCRIPTION )
SELECT T.new_inventory_transaction_ID, S.WORKORDER_TYPE, D.WORKORDER_BASE_ID,
  D.WORKORDER_LOT_ID, D.WORKORDER_SPLIT_ID, D.WORKORDER_SUB_ID, D.OPERATION_SEQ_NO,
  D.PIECE_NO, D.auto_issue_part_ID, S.TYPE, S.CLASS, D.[total_auto_issue Qty],
  0 AS Expr6, Date() AS Expr1, D.BACKFLUSH_WHS_ID, D.BACKFLUSH_LOC_ID,
  "SYSADM" AS Expr3, S.POSTING_CANDIDATE, S.ACT_MATERIAL_COST, S.ACT_LABOR_COST,
  S.ACT_BURDEN_COST, S.ACT_SERVICE_COST, Date() AS Expr2, S.ADD_BURDEN,
  S.COUNT_SEQUENCE, "ENTERED WITH ACCESS APP" AS Expr5
FROM tbl_static_autoissue_data AS S,
     tbl_dynamic_autoissue_data AS D,
     qry_transaction_ID_generator AS T;
  • 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-06-11T19:22:17+00:00Added an answer on June 11, 2026 at 7:22 pm

    Here are some notes that may help you towards your goal, however life would be a lot easier and a lot safer with autonumbers. This is VBA as you mention MS Access.

    Function NextTranNumber(ByRef FirstTran As Long, _
             ByRef LastTran As Long, Optional BlockSize = 1)
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strSQL As String
    Dim lngResult As Long
    Dim strCon As String
    
        lngResult = 0  'assume fail
    
        strCon = TestCon ''Connection to back-end
        cn.Open strCon
    
        rs.CursorType = adOpenKeyset
        rs.LockType = adLockPessimistic
        rs.CursorLocation = adUseServer
    
        ''Where BEInfo is a single line table that holds a transaction seed
        strSQL = "SELECT ASeqNumber FROM BEInfo"
    
        rs.Open strSQL, cn, , , adCmdText
    
        'Note this is ADO, so no rs.Edit
        FirstTran = rs!ASeqNumber + 1
        rs!ASeqNumber = rs!ASeqNumber + BlockSize
        rs.Update
    
        LastTran = rs!ASeqNumber
        rs.Close
        Set rs = Nothing
    End Function
    
    Sub TransactionProcessing()
    Dim FirstTran As Long
    Dim LastTran As Long
    Dim db As Database
    Dim sSQL As String
    Dim Block As Long
    Dim rs As DAO.Recordset
    
        Set db = CurrentDb
    
        'Existing temporary table
        sSQL = "DELETE FROM FETempTrans"
        db.Execute sSQL, dbFailOnError
        'The records to be added to the main table
        sSQL = "INSERT INTO FETempTrans ( ID, AText ) SELECT 0 AS ID, AText FROM Table1"
        db.Execute sSQL, dbFailOnError
    
        Block = db.RecordsAffected
    
        'Reserve a transaction block based on the temp table count
        NextTranNumber FirstTran, LastTran, Block
    
        Set rs = db.OpenRecordset("FETempTrans")
    
        Do While Not rs.EOF
            rs.Edit
            rs!ID = FirstTran
            rs.Update
            FirstTran = FirstTran + 1
            rs.MoveNext
        Loop
    
        If FirstTran - 1 = LastTran Then
            'compare the temp set to the main table
            'if it passes, update the main table
        Else
            'fail
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using an Access 2007 append query with parameters values, to enable a
I am attempting to run an Access append query in C# using OleDbCommand. As
I am using pythons built-in sqlite3 module to access a database. My query executes
Using Access 2003 Database Table1 Intime Outtime WorkTime OverTime 08:00:00 19:00:00 09:00:00 02:00:00 09:00:00
Using Access Database Table ID Time 001 100000 001 100005 001 103000 001 102500
I'm using Access 2003 and doing a make table query. The idea is, I
I have the following problem in a Database using Access 2007 as front end
I am working on access a database using F# and my initial attempt at
I am using MS Access Database. Now I have to update a particular cell
Using VB 6 and Access 2003 Code Dim db As Database, tbl As TableDef

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.