Advertisement

07.30.2008 at 02:21PM PDT, ID: 23609087
[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.3

code cleanup recommendations from Rick_Rickards

Asked by verpit in Access Forms, Microsoft Access Database

Rick_Rickards has stated that he needs to examine code in more detail to better determine what still needs to be cleaned up before attempting to gain scaleability for the form.  I have made the clean-up changes specified in question ID#23599300 and pasted the form code below along with the most recently corrected database and screenshot.

What do you think Rick?Start Free Trial
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:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
'----------------Form_frmTasks(Code)
 
Option Compare Database
Private Sub cmdAdd_Click()
    Dim strSQL As String
    Dim theTask As String, isActive As Boolean
    Dim dActivationDate As Date
    dActivationDate = Now()
    theTask = Me.txtText
    isActive = True
    'deactivate previously active record
    Set rs = CurrentDb.OpenRecordset("Select * from tblTasks where tblTasks.Active = True")
    If rs.RecordCount > 0 Then
        appendTblTasksLog rs("Task"), Not rs("Active"), dActivationDate
    End If
    deactivatePreviousTask Now()
    strSQL = "INSERT INTO tblTasks (Task,Active,ActivationDate) VALUES ('" & Me.txtText & "'" & "," & True & ",#" & dActivationDate & "#)"
    CurrentDb.Execute strSQL, dbFailOnError
    cmdClear_Click
    appendTblTasksLog theTask, isActive, dActivationDate
    Me.Requery
    Me!sfTasks.Requery
    Me!sfCompletedTasks.Requery
End Sub
Private Sub cmdClear_Click()
    Me.txtText = Null
End Sub
Private Sub Form_Open(Cancel As Integer)
    completeClicked = False
    activeClicked = False
    editClicked = False
    taskClicked = False
    With Me.sfCompletedTasks.Form
        .AllowAdditions = False
        .RecordSource = "Select * from tblTasks where Complete=True order by ActivationDate desc"
        Set .OtherSubForm = Me.sfTasks.Form
    End With
    With Me.sfTasks.Form
        .RecordSource = "select A.Complete,A.Task,A.Active,A.ActivationDate  from (Select top 6 * from tblTasks where Complete=False Order By Active, ActivationDate Asc) As A Order by A.Active Asc, A.ActivationDate Asc"
        Set .OtherSubForm = Me.sfCompletedTasks.Form
    End With
End Sub
Private Sub txtText_AfterUpdate()
    cmdAdd_Click
    Me.Requery
    Me!sfTasks.Requery
    Me!sfCompletedTasks.Requery
    Me!sfTasks.SetFocus
    Me.txtText.SetFocus          'Add this line to return focus back to txtText
End Sub
 
'-----------------Form_frmTasksSub(Code)
 
Option Compare Database
Option Explicit
Public OtherSubForm As Form
Public completeClicked As Boolean, activeClicked As Boolean
Public editClicked As Boolean, taskClicked As Boolean
Private Sub Active_AfterUpdate()
    activeClicked = True
    completeClicked = False
    Me.Requery
    OtherSubForm.Requery
    Form_frmTasks.sfTasks.SetFocus
End Sub
Private Sub Complete_AfterUpdate()
    activeClicked = False
    completeClicked = True
    Me.Requery
    OtherSubForm.Requery
    Form_frmTasks.sfTasks.SetFocus
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim rs As DAO.Recordset
    Dim sql As String
    Dim isActive As Boolean
    Dim dActivationDate As Date
    If editClicked = True Then
        editClicked = False
        Exit Sub
    End If
    dActivationDate = Now()
    Me!ActivationDate = dActivationDate
    If activeClicked Or completeClicked Or taskClicked Then
        If completeClicked Then
            If Me!Complete = True Then
                'was incomplete became complete
                Me!Active = False
            End If
            If Me.Complete = False Then
                'deactivate previously active record
                Set rs = CurrentDb.OpenRecordset("Select * from tblTasks where tblTasks.Active = True")
                If rs.RecordCount > 0 Then
                    appendTblTasksLog rs("Task"), Not rs("Active"), dActivationDate
                End If
                rs.Close
                deactivatePreviousTask dActivationDate
                Me!Active = True
            End If
        End If
        If activeClicked Then
            If Me!Active = True Then
                If Me!Complete = True Then Me!Complete = False
                'was inactive became active
                'deactivate previously active record
                Set rs = CurrentDb.OpenRecordset("Select * from tblTasks where tblTasks.Active = True")
                If rs.RecordCount > 0 Then
                    appendTblTasksLog rs("Task"), Not (rs("Active")), dActivationDate
                End If
                deactivatePreviousTask dActivationDate
            End If
        End If
        If Me.Active = False Then
            'was active became inactive
        End If
        'task clicked
        If taskClicked Then
            If Me!Active = True Then
                If Me!Complete = True Then Me!Complete = False
                'was inactive became active
                'deactivate previously active record
                Set rs = CurrentDb.OpenRecordset("Select * from tblTasks where tblTasks.Active = True")
                If rs.RecordCount > 0 Then
                    appendTblTasksLog rs("Task"), Not (rs("Active")), dActivationDate
                End If
                deactivatePreviousTask dActivationDate
            End If
        End If
        If Me.Active = False Then
            'was active became inactive
        End If
    End If
        'Append a new record in tblTasksMonitor
        appendTblTasksLog Me!Task, Me!Active, dActivationDate
End Sub
Private Sub Task_AfterUpdate()
    Me.Requery
    OtherSubForm.Requery
End Sub
Private Sub Task_Click()
    If editClicked = False Then
        'apply activation
        taskClicked = True
        Active = Not (Active)
        'RunCommand acCmdSaveRecord
    End If
    'Stop
    completeClicked = False
    activeClicked = False
    Me.Requery
    OtherSubForm.Requery
    Form_frmTasks.sfTasks.SetFocus
End Sub
Private Sub Task_DblClick(Cancel As Integer)
    editClicked = True
    Me!Task.Locked = False
End Sub
Private Sub Task_LostFocus()
    Me!Task.Locked = True
End Sub
Attachments:
 
task database
 
 
screenshot
screenshot
 
Related Solutions: obtaining sizing in form
[+][-]07.30.2008 at 07:20PM PDT, ID: 22126502

View this solution now by starting your 7-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

Zones: Access Forms, Microsoft Access Database
Sign Up Now!
Solution Provided By: hnasr
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.30.2008 at 07:29PM PDT, ID: 22126528

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 09:14PM PDT, ID: 22126844

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 09:31PM PDT, ID: 22126907

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208