VBA Resources For MS Access

Christopher Rath

2006-09-08

 

MS Access

These are MS Access-specific VBA tips:

Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Const ColorRed As Long = 255
    Const ColorAmber As Long = 65535
    Const ColorBlue As Long = 16711680
    Const ColorGreen As Long = 13434828
    Const ColorWhite As Long = 16777215
    Const ColorBlack As Long = 0
    
    Const BackStyleTransparent As Long = 0
    Const BackStyleNormal As Byte = 1

    Select Case Me![Stoplight Short]
        Case "B"
            Me![Stoplight Short].ForeColor = ColorWhite
            Me![Stoplight Short].BackColor = ColorBlue
            Me![Stoplight Short].BackStyle = BackStyleNormal
        Case "G"
            Me![Stoplight Short].ForeColor = ColorBlack
            Me![Stoplight Short].BackColor = ColorGreen
            Me![Stoplight Short].BackStyle = BackStyleNormal
        Case "Y", "A"
            Me![Stoplight Short].ForeColor = ColorBlack
            Me![Stoplight Short].BackColor = ColorAmber
            Me![Stoplight Short].BackStyle = BackStyleNormal
        Case "R"
            Me![Stoplight Short].ForeColor = ColorWhite
            Me![Stoplight Short].BackColor = ColorRed
            Me![Stoplight Short].BackStyle = BackStyleNormal
        Case "?"
            Me![Stoplight Short].ForeColor = ColorBlack
            Me![Stoplight Short].BackColor = ColorWhite
            Me![Stoplight Short].BackStyle = BackStyleTransparent
        Case Else
            Me![Stoplight Short].ForeColor = ColorBlack
            Me![Stoplight Short].BackColor = ColorWhite
            Me![Stoplight Short].BackStyle = BackStyleTransparent
    End Select
End Sub

Other Resources

See the page that linked to this one for other VBA resources I have found helpful.


©Copyright 2005–2006, Christopher Rath
Address: 1371 Major Rd., Ottawa, ON, Canada K1E 1H3
Last updated: 2016/05/15 @ 17:58:12 ( )