Colour up/dow record

Dreamweaver

Well-known member
Local time
Today, 10:51
Joined
Nov 28, 2005
Messages
2,467
I have attached an image of what I am trying to do I have some small up/down buttons that do what thay say but my problem has been with getting confused when moving a record up or down so I came up with a plan to colour the record being moved I'm sure I can do this useing another field in the table but I really want to avoid that if I can so thought I would put it out to the pros.


P.S. Edit: my intention is to use conditional formating


thanks
 

Attachments

  • 2018-12-29 (5)_LI.jpg
    2018-12-29 (5)_LI.jpg
    111.9 KB · Views: 84
Last edited:
Ended up using a leftover boolean that's not being used


Code:
Private Sub Spin_Down_Click()
Dim m_Db As Database
Dim CurDoID As String
Dim CloneIt As Recordset

On Error GoTo HandleErr


If Me.Dirty Then RunCommand acCmdSaveRecord
Set m_Db = CurrentDb()

Set CloneIt = Me.RecordsetClone

If Me![Level] < CloneIt.RecordCount Then
'Move those bELOW entry Up one place
CurDoID = Me![TaskID]
m_Db.Execute ("UPDATE tblTasks SET [Level]=[Level]-1 WHERE [PhaseID]='" & Me![PhaseID] & "'" & " And [Level]=" & Me![Level] + 1)
m_Db.Execute ("UPDATE tblTasks SET [Level]=[Level]+1,[PrintFlag]=True WHERE [TaskID]='" & CurDoID) & "'"

End If
Me.Requery
m_Db.Close

HandleExit:
    Exit Sub
    
HandleErr:
    Select Case Err.Number
        Case 2501 'Cancel = True
            Exit Sub
        Case Else
            Call GlobalErrs(Err.Number, Err.Description, Err.Source, "ZfrmEstimateTasks", "Spin_Down_Click")
            Resume HandleExit
        Resume
    End Select
End Sub

Private Sub Spin_Up_Click()
Dim m_Db As Database
Dim CurDoID As String

On Error GoTo HandleErr

If Me.Dirty Then RunCommand acCmdSaveRecord
Set m_Db = CurrentDb()

If Me![Level] > 1 Then
'Move those above entry down one place
CurDoID = Me![TaskID]
m_Db.Execute ("UPDATE tblTasks SET [Level]=[Level]+1 WHERE [PhaseID]='" & Me![PhaseID] & "'" & " And [Level]=" & Me![Level] - 1)
m_Db.Execute ("UPDATE tblTasks SET [Level]=[Level]-1,[PrintFlag]=True WHERE [TaskID]='" & CurDoID) & "'"

End If
Me.Requery
m_Db.Close

HandleExit:
    Exit Sub
    
HandleErr:
    Select Case Err.Number
        Case 2501 'Cancel = True
            Exit Sub
        Case Else
            Call GlobalErrs(Err.Number, Err.Description, Err.Source, "ZfrmEstimateTasks", "Spin_Up_Click")
            Resume HandleExit
        Resume
    End Select
End Sub


Private Sub ZfrmEstimateTasks_Exit(Cancel As Integer)
On Error GoTo HandleErr

CurrentDb.Execute ("UPDATE tblTasks SET [PrintFlag]=False WHERE [PhaseID]='" & Me![CboPhases] & "'" & " And [PrintFlag]=True")
Me.ZfrmEstimateTasks.Requery

HandleExit:
    Exit Sub
    
HandleErr:
    Select Case Err.Number
        Case 2501 'Cancel = True
            Exit Sub
        Case Else
            Call GlobalErrs(Err.Number, Err.Description, Err.Source, "frmEstimates", "ZfrmEstimateTasks_Exit")
            Resume HandleExit
        Resume
    End Select
End Sub


Added a few images that might be of use should anybody wish to do something like this
 

Attachments

  • 2018-12-30.jpg
    2018-12-30.jpg
    111.7 KB · Views: 65
  • 2018-12-30 (1).png
    2018-12-30 (1).png
    37.8 KB · Views: 68
built an example of this as was a lot more then was above awaiting approval at the moment then will link it here
 
Last edited:

Users who are viewing this thread

Back
Top Bottom