Results 1 to 3 of 3
  1. #1
    Andys is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    1

    Unhappy Issues with Access 2013 combo box

    Hello Community,

    I am new to Access and VB. The first database I created was with an experienced DB and he guided me to make input forms where users can add names or room numbers. When you would click the 'save' button, it would write to the respected table. When you click the 'delete' button, it would delete the record. Both would re-query the results. This was created in MS Access 2010.

    So, I have copied the same VB code and setup everything correctly (from what I can see) to a new DB dealing with titles. This is in MS Access 2013.

    The two issues I am having is saving/adding a new title and deleting a title.

    When I select a title from the combo box, and click delete, I receive the follow error:
    "Run-time error '-2147352567 (80020009)':
    Record in table 'Software_Title_Table' was delete by another user."

    I don't understand or know how that is possible! So, I click on Debug and this is what is highlighted in yellow:
    Me.Software_Title = Null

    Here is the VB code for the delete button:

    Private Sub STDeleteB_Click()
    Dim db As Database
    Dim sftt As Recordset
    Set db = CurrentDb
    Set sftt = db.OpenRecordset("Software_Title_Table", DB_OPEN_DYNASET)

    With sftt
    .Edit
    Do Until .EOF = True

    If Me.Software_Title = sftt![Software_Title] Then GoTo deletethis
    sftt.MoveNext
    Loop

    Exit Sub

    deletethis:

    .Delete
    End With
    Me.Software_Title = Null
    Me.Software_Title.Requery


    End Sub

    It work perfectly fine in the other database, but here I am not sure why.

    The second issue is with the save/add button. When I click in the empty combo box and type a title 'Firefox' and click save, I receive the follow error:

    "The text you entered isn't an item in the list.
    Select an item form the list, or enter text that matches on of the listed items."

    This doesn't happen on the original DB. Not sure if a feature in 2013 is making it happen from 2010.
    Here is the VB code for the save button:

    Private Sub STSaveB_Click()
    Dim db As Database
    Dim sftt As Recordset

    Set db = CurrentDb
    Set sftt = db.OpenRecordset("Software_Title_Table", DB_OPEN_DYNASET)

    With sftt
    .AddNew
    ![Software_Title] = Me.Software_Title
    .Update
    End With
    Me.Software_Title = Null
    Me.Software_Title.Requery
    End Sub

    Here is the whole VB code for the form I am dealing with:

    Option Compare Database

    Private Sub Combo8_Click()
    Me.Requery
    End Sub
    ---------------
    Private Sub STCloseB_Click()
    DoCmd.Close acForm, "Software_Title_Table_Form", acSaveYes
    End Sub
    --------------------------
    Private Sub STDeleteB_Click()
    Dim db As Database
    Dim sftt As Recordset
    Set db = CurrentDb
    Set sftt = db.OpenRecordset("Software_Title_Table", DB_OPEN_DYNASET)

    With sftt
    .Edit
    Do Until .EOF = True

    If Me.Software_Title = sftt![Software_Title] Then GoTo deletethis
    sftt.MoveNext
    Loop

    Exit Sub

    deletethis:

    .Delete
    End With
    Me.Software_Title = Null
    Me.Software_Title.Requery
    End Sub
    --------------------------------
    Private Sub STSaveB_Click()
    Dim db As Database
    Dim sftt As Recordset

    Set db = CurrentDb
    Set sftt = db.OpenRecordset("Software_Title_Table", DB_OPEN_DYNASET)

    With sftt
    .AddNew
    ![Software_Title] = Me.Software_Title
    .Update
    End With
    Me.Software_Title = Null
    Me.Software_Title.Requery
    End Sub
    ---------------------------

    What I am trying to accomplish is in the 'Software Title' Form, a user can click on the drop-down list (which is queried from the 'Software Table') and see what titles are in there. They should be able to click a title and click the delete button if they need to. They should also be able to select the blank field in the drop-down list and type a title name, Firefox or Adobe and click save, which should then write it to the 'Software Title' table.

    I would have posted pictures, but since I am new, I don't have the 10 posts yet.

    I would appreciate any assistance from you all if possible. Again, I am a novice with it comes to Access and VB so if you could explain it in lamance terms or add what I need to do to my VB and point it out, that would be very appreciated.

    Thanks,

    Andy

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Sounds like the combobox LimitToList property is set to Yes.

    Why is code needed to save record and update record? Sounds like the forms are not bound. Forms bound to table do not require code to enter/edit data. Bound forms and controls pass the data directly to the table fields.

    If code must be used to add or delete record, it is not usually necessary to open a recordset to do that. I would execute an SQL action statement.

    CurrentDb.Execute "DELETE FROM Software_Title_Table WHERE Software_Title='" & Me.Software_Title & "'"

    Deleting records should be a rare event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    that is way too much code

    as a self described novice - head over to a big box bookstore or amazon and pick up 'Access Step by Step'..... adding a combo box to a form involves no coding at all.......

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

Similar Threads

  1. Replies: 3
    Last Post: 02-26-2014, 05:11 PM
  2. Outlook 2013 + Access 2013 + HTML
    By Yann63 in forum Programming
    Replies: 2
    Last Post: 11-26-2013, 02:39 PM
  3. Access 2013 Web App with Sharepoint 2013
    By miguel.escobar in forum Access
    Replies: 7
    Last Post: 06-17-2013, 09:03 AM
  4. Cascade Combo Box - Help! Access 2013
    By alamp85 in forum Forms
    Replies: 4
    Last Post: 04-09-2013, 03:49 PM
  5. Access 2003 - cascading combo box issues
    By agripa86 in forum Access
    Replies: 1
    Last Post: 08-12-2011, 06:20 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