Results 1 to 7 of 7
  1. #1
    Business is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    78

    Stuck concerning the update and the inserting into a table field vba codes

    Hi,


    I m a, currently working on a stock inventory database but i got problems updating and inserting field.
    I have a table,FactInside where i want the field to be saved and while saving it has to update the quantity in stock table after an item has been bought.
    In the form i have a combo box that is divided im 3 (Name,prixvenduI,and produitQuantite) . After choosing a product the substraction is done on the form and the new quantity has to be updated in Stock table.
    I keep getting an error ,essage saying wrong syntax.
    This is the code
    Dim strSQL As String
    Dim strSQ As String
    Dim rst As DAO.Recordset
    Dim fact As Integer
    Dim factdate As Date
    Dim produitNom As String
    Dim prixvendu As Integer
    Dim quantite As Integer
    factdate = Me.factInsideDate
    produitNom = Me.Modifiable15.Column(2)
    prixvendu = Me.prixvenduI
    quantite = Me.quantiteSortiI






    strSQL = "UPDATE Stock Set [produitQuantite] = " & Me.Texte17 & " WHERE [produitId] = " & Me.Modifiable15
    CurrentDb.Execute strSQL, dbFailOnError




    strSQ = "INSERT INTO FactureInside(FactInsideId,factInsideDate,produitN om,prixvenduI,quantiteSortiI)"
    strSQ = strSQ & " VALUES (" & fact & ", #" & factdate & "#," & produitNom & ", " & prixvendu & ", " & quantite & ");"


    CurrentDb.Execute strSQ, dbFailOnError
    Can anyone tell me how to go about it.

    Regards

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    After choosing a product the substraction is done on the form
    The syntax looks OK in the face of it - however what control does this subtraction? Me.Texte17? Appreciate you are using a different language, but shouldn't this be Me.Text17?

    I won't go into the problems of storing calculated values such as this

  3. #3
    Business is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    78
    Quote Originally Posted by Ajax View Post
    The syntax looks OK in the face of it - however what control does this subtraction? Me.Texte17? Appreciate you are using a different language, but shouldn't this be Me.Text17?

    I won't go into the problems of storing calculated values such as this

    Yes it s Me.Texte17 that does the calculation. It s giving me a syntax error

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    so how is the value calculated exactly - include, brackets, proper field names etc

  5. #5
    Business is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    78
    Quote Originally Posted by Ajax View Post
    so how is the value calculated exactly - include, brackets, proper field names etc
    Private Sub quantiteSortiI_AfterUpdate()
    Me.Texte17.Value = Me.Texte17.Value - Me.quantiteSortiI.Value
    'DoCmd.RunCommand acCmdSaveRecord
    End Sub
    And from there i do update the stock table

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I'd put a break on this line CurrentDb.Execute strSQL, dbFailOnError for each and mouse over the variables to see if they are as expected. Maybe this Me.Modifiable15 is text, in which case quotes are missing. If it is a name issue, that should indicate there's a problem there, but I think you can call a textbox Texte if you want - it's simply French for text. There are places where English must be used, but I don't think this is one of them.

    Maybe this is a two column combo Me.Modifiable15.Column(2) which would mean he's probably trying to use a Null for produitNom. Again, the break should help if one knows what to look for.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Business,

    Stock/Inventory control is not a trivial subject. Getting your tables and relationships set up to meet your business requirements is critical.
    Can you show us a screen capture (jpg) of your relationships window?

    A few links that may be useful to you. This is for info only. You may use, adjust or ignore as applicable to your set up.
    Allen Browne Stock Taking info

    youtube video on stock Control application

    blueclaw info

    Free data model from Barry Williams' site

    Good luck
    Last edited by orange; 04-16-2016 at 10:19 AM. Reason: inventory, stock, control

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 04-03-2016, 08:36 PM
  2. UPC codes: what field type do ppl use?
    By crobaseball in forum Access
    Replies: 1
    Last Post: 07-23-2015, 03:13 PM
  3. Replies: 4
    Last Post: 10-08-2011, 06:31 AM
  4. Consolidation codes from different table.
    By suverman in forum Queries
    Replies: 3
    Last Post: 05-13-2011, 10:39 AM
  5. Inserting a New Field in Middle of Table
    By AccessGeek in forum Programming
    Replies: 4
    Last Post: 03-14-2011, 09:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums