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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:56:21+00:00 2026-05-30T15:56:21+00:00

I have the following coding for a button. My problem is that the Query

  • 0

I have the following coding for a button. My problem is that the Query “SQLStory” is comming up with an error that it is missing a semi colon.

The combobox contains the item name and is ordered by the product ID and the SQLStory is supposed to move all items from the TblTotalSale to the table TblSaleStore. Any Ideas where the error is?

Private Sub StockOK_Click()
Dim SQLDelete1 As String
Dim SQLDelete2 As String
Dim SQLUpdate As String
Dim SQLStory As String

SQLDelete1 = "DELETE * FROM TblStock WHERE TblStock.ProductID = " & CboStockItem.Value
SQLDelete2 = "DELETE * FROM TblTotalSale WHERE TblTotalSale.ProductID = " & CboStockItem.Value
SQLUpdate = "INSERT INTO TblStock (ProductID, StockLevel) VALUES ( " & Me.CboStockItem.Value & "," & Me.TxtStockValue & " )"
SQLStory = "INSERT INTO TblSaleStore (ProductID) VALUES (TblTotalSale.ProductID) FROM TblTotalSale WHERE TblTotalSale.ProductID = " & Me.CboStockItem.Value


If IsNull(Me.TxtStockValue) Then MsgBox "Please Select An Item To Update Stock And Ensure A Value Has Been Entered" Else:
DoCmd.RunSQL SQLDelete1
DoCmd.SetWarnings False
DoCmd.RunSQL SQLStory
DoCmd.RunSQL SQLDelete2
DoCmd.RunSQL SQLUpdate
DoCmd.SetWarnings True


End Sub

Another problem I am having with this code is that the block of doCmd was happening whether the txt box TxtStockValue was null or not, and I only want them to happen if the box is not null… Any Ideas on that part either?

Thanks

Sam

  • 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-30T15:56:22+00:00Added an answer on May 30, 2026 at 3:56 pm

    Values are for just that, values such as ‘abc’ or 123, you need SELECT:

    SQLStory = "INSERT INTO TblSaleStore (ProductID) " _
             & "SELECT (TblTotalSale.ProductID) FROM " _
             & "TblTotalSale WHERE TblTotalSale.ProductID = " _
             & Me.CboStockItem.Value
    

    But the above is odd, because you already have the ID in the combo, so, as I said in your previous post on the topic:

    SQLStory = "INSERT INTO TblSaleStore (ProductID) " _
             & "VALUES ( " &  Me.CboStockItem.Value & " )"
    

    Also, it was suggested to you that you should use debug.print when using SQL, this would allow you to view the SQL and paste it into the query design window to see if it worked. The debug.print line can be commented out when everything is working. When you are unfamiliar with SQL, there is a lot to be said for using the query design window to build your queries. You can then cut the SQL from SQL View and add quotes etc.

    EDIT re Question Part 2

    Dim db As Database
    Set db = CurrentDB
    
    If IsNull(Me.TxtStockValue) Then 
        MsgBox "Please Select An Item To Update Stock " _
               & "And Ensure A Value Has Been Entered" 
    Else
       db.Execute SQLDelete1, dbFailOnError
       ''DoCmd.SetWarnings False
       db.Execute SQLStory, dbFailOnError
       db.Execute SQLDelete2, dbFailOnError
       db.Execute SQLUpdate, dbFailOnError
       ''DoCmd.SetWarnings True
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following have been proposed for an upcoming C++ project. C++ Coding Standards, by
I have the following coding: <div class=product-top-icons> <div class=energy-rating-1><img src=http://www.justhome.co/skin/frontend/default/just2011/images/assets/<?php echo $_product->getAttributeText('energy_rating_one');?>.jpg></div> <div class=energy-rating-2><img
I have seen lot projects following this kind of coding style Any significant advantage
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following situation. A main table and many other tables linked together with
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following text in a file 23456789 When I tried to replace the

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.