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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:13:08+00:00 2026-06-11T20:13:08+00:00

I am trying to make a small inventory program using Access but I don’t

  • 0

I am trying to make a small inventory program using Access but I don’t have much knowledge, whatever I have done so far is by googling stuff. I Have managed to make code to store data using unbound forms, now I want to update some particular fields of a table by data entered in an unbound form for another table. The 2 tables in question are Transaction and Stock. Stock has 3 fields PartNo, Location and Qty. I want the QTY in stock to be deducted from the location where stock is moving out of, and to be added to where it is going to.

Sample data in table Stock

Stock_PartNo    Stock_Location  Stock_Qty
2288            SAWRH001        85
2288            SAWRH002        54
3214            SAWRH003        544
4567            SAWRH001        32
5555            SAWRH002        128
5555            SAWRH005        874
5678            SAWRH002        321
6544            SAWRH004        465
6666            SAWRH003        45
6666            SAWRH004        87
7777            SAWRH003        365
7890            SAWRH002        352
8765            SAWRH005        57
8888            SAWRH004        54
9999            SAWRH005        21

Here is my code for an unbound form:

Private Sub Command39_Click()

Dim db As Database, rsCust As Recordset


    Set db = CurrentDb
    Set rsCust = db.OpenRecordset("Transaction", DB_OPEN_DYNASET)

        rsCust.AddNew
        rsCust("Trans_PartNo") = Me!Combo52
        rsCust("Trans_Desc") = Me!Text19
        rsCust("Trans_Disp") = Me!Text21
        rsCust("Trans_Recv") = Me!Text23
        rsCust("Trans_Qty") = Me!Text25
        rsCust("Trans_Date") = Me!Text29
        rsCust.Update

        MsgBox "Material transfer information has been updated"

        Call ClearControls

    rsCust.Close
    db.Close
End Sub

This data would be stored in a table called Transaction which is just a record history of what was moved from one place to another. What I want is that table Stock should be updated using this form, so if PartNo 2288 is transferred from SAWRH001 to SAWRH005 then it should update table Stock automatically. As far as I understand I need to embed a SQL query but I don’t know how to do that in VBA.

  • 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-11T20:13:09+00:00Added an answer on June 11, 2026 at 8:13 pm

    With parameters:

    Dim db As Database
    Dim qdf As QueryDef
    
    Set db = CurrentDb
    sSQL = "UPDATE Stock SET Stock_Qty = Stock_Qty + [p1] " & _
         " WHERE Stock_PartNo = [p2] AND Stock_Location = [p3]"
    
    ''Temporary query
    Set qdf = db.CreateQueryDef("", sSQL)
    ''No need to worry about quotes etc
    qdf.Parameters("p2") = Me!Combo52
    
    ''Subtract
    qdf.Parameters("p1") = Me.Text25 * -1
    qdf.Parameters("p3") = Me.From
    qdf.Execute dbFailOnError
    
    ''Add
    qdf.Parameters("p1") = Me.Text25
    qdf.Parameters("p3") = Me.To
    qdf.Execute dbFailOnError
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a small pizza order form, but I have a
I am trying to make small calculator in jquery but don't know where to
I'm trying to make a small game using both SFML and Box2D. I have
Trying to make a small countdown timer in my app but it's not working.
I am trying to make a small application for my arm target. I have
I'm trying to make a small program that could intercept the open process of
I finished my small application and I am trying to make sure I have
i m trying to make small test driven example by using cppunit. So i
I'm trying to make a small program more robust and I need some help
I'm trying to make a small VBScript that compacts a MS Access 2007 database

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.