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

    update issues

    Hi,
    I got a problem in my codes.I m updating on a table from a button but when opening the table it does not save the fied but the autonumber attached to the field.Those are the codes
    Private Sub Commande22_Click()
    Dim strSQL As String


    strSQL = "UPDATE Stock Set [produitQuantite] = " & Me.Texte15 & " WHERE [produitId] = " & Me.Modifiable13


    CurrentDb.Execute strSQL, dbFailOnError
    Me.Texte15 = ""
    Me.Texte17 = ""
    Me.Texte19 = ""
    End Sub

    Me.Modifiable13 is a combo box containing 3 column but choosing only one appear on the form.After saving its saves the primary key
    Help please

  2. #2
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Have you tried debugging your data? my guess from doing it is that your form data types are not matching your table.

    Code:
    Dim strSQL As String
    
    
     strSQL = "UPDATE Stock Set [produitQuantite] = " & Me.Texte15 & " WHERE [produitId] = " & Me.Modifiable13
    debug.print(StrSQL)
    debug.print(me.texte15)
    debug.print(Me.Modifiable13)
     CurrentDb.Execute strSQL, dbFailOnError
     Me.Texte15 = ""
     Me.Texte17 = ""
     Me.Texte19 = ""
     End Sub
    I see two immediate possibilities though, what is the bound column of the combo, it can be different that whats displayed, and did you spell texte15 on the form the same as in your code. why the "e" on the end?

  3. #3
    Business is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    78
    Yes Texte15 is well written.Me.modiafiable13 displays 3 values.The name,the price and the wuantity inn stock.I have selected the produitId to facilitate the update but it does not display as well when opening it.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    With bound combo's, the visible column(s) of a combo is not necessarily the same as the bound column. Your problem is that by not specifying which column in Me.Modifiable13 you are getting the bound column value (probably the left-most one). Check the left to right order of the columns and specify which to use (and this number is zero based) or if this is an unbound combo, simply put the one you want to use by default first in the left to right order. The whole subject can be difficult to explain in a short post and the solution can depend on if the combo is bound or not. Suggest you Google combo boxes for Access and ensure you understand how they work or you will be continually and unnecessarily frustrated by them.

    And for the benefit of others, Texte is French and Access does not care if it's English or even Klingon when it comes to control names.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    ok that makes sense on the control name. Business, did you try using the code i posted back, did the values in the immediate window match your data types?

  6. #6
    Business is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2016
    Posts
    78
    Sorry for the delay i was a bit busy. unfortunatly it did not work.Let me explain it more clearly to you.
    There is a table stock and table invoice,a form Invoice and two button save and update On the table stock there is productId and productName and productprice.
    The invoice table has InvoiceNumber,productId(For the relationship) and product name.
    Me.Modifiable13 is a combo box containing the productId,productPrice and productQuantity).
    On the invoice form i do not display the productId,Me.Modifiable13 display a name. But while updating the table and saving,the value of productname is a number and on productId there is a zero.
    Help please i have tried everything i know
    Codes
    strSQL = "UPDATE Stock Set [produitQuantite] = " & Me.Texte15 & " WHERE [produitId] = " & Me.Modifiable13


    CurrentDb.Execute strSQL, dbFailOnError
    Me.Texte15 = ""
    Me.Texte17 = ""
    Me.Texte19 = ""

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

Similar Threads

  1. Report Update Issues
    By David O'Neil in forum Reports
    Replies: 2
    Last Post: 02-15-2016, 10:06 PM
  2. Update Form & Combobox Issues
    By MarkMcAllister in forum Forms
    Replies: 4
    Last Post: 05-28-2015, 05:29 PM
  3. Subform issues
    By spqr in forum Forms
    Replies: 3
    Last Post: 10-14-2013, 08:53 AM
  4. Replies: 10
    Last Post: 09-18-2012, 02:00 PM
  5. Replies: 1
    Last Post: 03-23-2010, 04:01 PM

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