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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:32:27+00:00 2026-06-12T10:32:27+00:00

I am making a rather simple inventory tracking database. And I want to retrieve

  • 0

I am making a rather simple inventory tracking database. And I want to retrieve the record by ID, and add or remove the specified number to the amount. If it doesn’t exist I want to add it. Is it even possible to do this without binding to a table?

  • 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-12T10:32:29+00:00Added an answer on June 12, 2026 at 10:32 am

    Sounds like you have a candidate ID value. Maybe it’s contained in a numeric variable named MyID. And you have another numeric value, MyAmtChange, which is to be added to the value in a field named amount in your table for the row where the ID field value matches MyID.

    A complication is there may be no row in your table whose ID value matches MyID. In that case, you need to add a row for it.

    If that’s correct, INSERT a row for MyID when one doesn’t exist. Then you can simply UPDATE the amount in the row which matches MyID.

    Dim strInsert As String
    Dim strUpdate As String
    Dim db As DAO.Database
    
    Set db = CurrentDb
    If DCount("*", "YourTableNameHere", "ID = " & MyID) = 0 Then
        strInsert = "INSERT INTO YourTableNameHere (ID)" & vbCrLf & _
            "VALUES (" & MyID & ");"
        Debug.Print strInsert
        db.Execute strInsert, dbFailOnError
    End If
    
    strUpdate = "UPDATE YourTableNameHere" & vbCrLf & _
        "SET amount = Nz(amount, 0) + " & MyAmtChange & vbCrLf & _
        "WHERE ID = " & MyID & ";"
    Debug.Print strUpdate
    db.Execute strUpdate, dbFailOnError
    Set db = Nothing
    

    If this guess is reasonably close, add an error handler block to that code to deal with any issues surfaced by dbFailOnError … or any other errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always stumble upon this (rather simple question) when making e.g. Wordpress blogs. Should
I'm rather new to C and have recently been working on making a simple
I'm making a rather simple app that displays a table where each row contains
I'm making a rather simple piece of software and at the moment I'm working
This is a rather simple question that is making me a bit curious. Consider
I'm making a straightforward barchart in R using the ggplot2 package. Rather than the
Making a simple application, so when the user logs out of Windows, it of
I would like to write a rather simple content application which displays a list
Im making a simple proof of concept page with jQuery: $('.notclicked').click(function() { $(this).addClass(clicked); $(this).removeClass(notclicked);
I'm making a simple game in XNA (for Windows, if that makes a difference),

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.