Results 1 to 8 of 8
  1. #1
    Master Klick is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jul 2013
    Posts
    47

    Form won't update table

    I created a new form using form design. This form will not allow me to make changes to my table.



    When I use "Form" instead of "Form Design" it will allow me to set up controls to edit the table.

    Does anyone know what the difference is there? Is there anything I can do to fix that?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    That does not make sense. A form's properties can dictate if a field or all fields can be edited, etc.

    Start with the form's recordset. Is it based on a table or a query? If it is a query, open the query object and see if you can edit the fields. Then move to the form's properties; Allow Edits, Allow Additions, Allow Deletions. Also control properties; Locked, Enabled

  3. #3
    Master Klick is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jul 2013
    Posts
    47
    Quote Originally Posted by ItsMe View Post
    That does not make sense. A form's properties can dictate if a field or all fields can be edited, etc.

    Start with the form's recordset. Is it based on a table or a query? If it is a query, open the query object and see if you can edit the fields. Then move to the form's properties; Allow Edits, Allow Additions, Allow Deletions. Also control properties; Locked, Enabled

    The recordset is based on a query and I can edit the fields in it. In the form, edits, additions and deletions are allowed. The control is enabled.

    I tried having VBA edit the quantity in both the query:

    Private Sub PlusOne_Click()
    DoCmd.SetWarnings False
    Dim strSQL As String
    strSQL = "UPDATE [InvQuery] SET [Quantity] = [Quantity] + 1 " & _
    "WHERE [InvQuery].[ID] = " & Me!
    [List] & ";"
    DoCmd.RunSQL strSQL
    Me!List.Requery
    DoCmd.SetWarnings True
    End Sub

    And the table:

    Private Sub PlusOne_Click()
    DoCmd.SetWarnings False
    Dim strSQL As String
    strSQL = "UPDATE [Inventory] SET [Quantity] = [Quantity] + 1 " & _
    "WHERE [Inventory].[ID] = " & Me!
    [List] & ";"
    DoCmd.RunSQL strSQL
    Me!List.Requery
    DoCmd.SetWarnings True
    End Sub

    In both cases a window pops up asking me to enter a quantity. When I hit ok I get the error.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Now I am more confused. Your action queries should work with the exception of...

    "WHERE [InvQuery].[ID] = " & Me!

    [List] & ";"

    when I paste it into a text file it has a return. Should be in one line.

    Code:
    "WHERE [InvQuery].[ID] = " & Me!
    [List] & ";"
    If that is the problem, the error you are getting should be something about missing operator or something SQL. So, line continuation is probably not it.

    EDIT: The line continuation thing is the bracket and how HTML handles it. Never mind line continuation


    Not sure I know what "pops up asking me to enter a quantity" is. Does your form have a control bound to a field name that does not exist in the query? I do not understand the error.

    Your post does not add up when you state "edits, additions and deletions are allowed. The control is enabled". This means that all is well and you should be able to open the form and edit records. The only other property to consider would be the form's Data Entry property. I do not see any problems. Maybe you can describe the error in more detail.

    Those click events should function autonomously.
    Last edited by ItsMe; 01-13-2014 at 08:23 PM. Reason: Just noticed.....

  5. #5
    Master Klick is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jul 2013
    Posts
    47
    Help.zip

    Ok, I attached the file. Had to delete most of the records but it still works the same.

    In the InvForm, the + and - buttons next to the picture, that's what I can't get working.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Couple of things.

    First, when you have a desire to edit fields or UPDATE fields, make syre the query you are using is updateable. In this case, there is not a need to use a query since you are only updating one field. Suggest you use the table object in your UPDATE query statement.

    Second, there is not a Quantity field in your table or query that I could see.

    Code:
    Private Sub PlusOne_Click()
    If IsNull(Me.List) Then
    MsgBox "Please make a selection before proceeding.", vbCritical, "Request Cancelled"
    Exit Sub
    End If
    
    DoCmd.SetWarnings False
    Dim strSQL As String
    strSQL = "UPDATE [Inventory] SET [Qty] = [Qty] + 1 " & _
              "WHERE [Inventory].[ID] = " & Me!
    [List] & ";"
    'strSQL = "UPDATE Inventory SET Inventory.Qty = [Qty] +1 " & _
    '"WHERE [Inventory].[ID] = 24325"
    DoCmd.RunSQL strSQL
    Me!List.Requery
    DoCmd.SetWarnings True
    End Sub
    I added some code to make sure a selection in the listbox was made. Also, notice the commented out code. Hardcoding values can be useful when troubleshooting. In this case, nothing was wrong with your listbox properties, etc. but it allowed me to stay focussed on the problem at hand.

  7. #7
    Master Klick is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jul 2013
    Posts
    47
    OMG! I'm such an idiot. In the table I named it "Qty". I suppose I should probably set to the code to refer to what I actually named the field.

    Thanks for all the help.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Not a problem. Glad you got it sorted.

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

Similar Threads

  1. Replies: 7
    Last Post: 09-21-2012, 11:09 AM
  2. Replies: 7
    Last Post: 05-14-2012, 08:33 PM
  3. Use a form to Update a table
    By j2curtis64 in forum Forms
    Replies: 0
    Last Post: 04-05-2011, 10:18 AM
  4. Replies: 2
    Last Post: 12-22-2010, 01:46 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