[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Using VBA to edit record and delete records

Asked by Dan89 in Access Coding/Macros

Tags: Microsoft, Access, 2007

I have table (supplier) which simply combines two primary keys from two other tables Contacts and Items, supplier uses the primary key from items as its own primary key. In a certain form there are two list boxes and an option box with 3 radio buttons. The 3 options are, Do nothing, Change to another free item and delete item. The first list box uses a query to show all items that are currently attached to the contact which is in question (as a contact can have more than one different item) from the supplier table.  The other list box runs a similar query that compares the items in the supplier table and those that are in the items table, and displays those that are not in supplier. These are free items and are awaiting to be combined with a contact in the supplier table. When the first and third options are selected the second list box is disabled, when  the second option is selected the second list box is enabled. What I want to happen is the user selects an option from the first list box, then choose an option, should that be option 1, nothing should happen. When option 2 is selected, the itemID from the first list box is replaced by that in the second list box. When the third option is selected the record selected in the first list box should be deleted. These events are triggered by a button click. I am currently using the code shown to achieve this, nothing happens to any records although there is no errors. Any suggestions?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
Private Sub btnSaveChange_Click()
Select Case Me!FrameOptions
Case 1
DoCmd.Close
 
Case 2
    If [LstItems].Value <> 0 Then
    
        Dim OldItems As New ADODB.Recordset
    
        OldItems.Open "Supplier", CurrentProject.Connection, _
            CursorType:=adOpenKeyset, LockType:=adLockBatchOptimistic
            
        Do While Not OldItems.EOF
            If OldItems("ItemID") = [LstItems].Value Then
                OldItems("ItemID") = [lstFreeItems].Value
                OldItems.Update
            End If
            OldItems.MoveNext
        Loop
    Else
        MsgBox ("No items are assigned to this contact")
    End If
    DoCmd.Close
Case 3
    Dim Items As New ADODB.Recordset
    
    Items.Open "Supplier", CurrentProject.Connection, _
        CursorType:=adOpenKeyset, LockType:=adLockBatchOptimistic
        
    Do While Not Items.EOF
        If Items("ItemID") = [LstItems].Value Then
            Items.Delete
            Items.Update
        End If
        Items.MoveNext
    Loop
    DoCmd.Close
End Select
End Sub
[+][-]02/06/08 08:01 AM, ID: 20833052Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/06/08 08:19 AM, ID: 20833244Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/06/08 08:26 AM, ID: 20833305Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/06/08 08:38 AM, ID: 20833410Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/06/08 08:50 AM, ID: 20833513Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Access Coding/Macros
Tags: Microsoft, Access, 2007
Sign Up Now!
Solution Provided By: LSMConsulting
Participating Experts: 2
Solution Grade: A
 
[+][-]02/06/08 09:11 AM, ID: 20833722Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_2_20070628