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