check marks not turning black

I got help from the experts and everything is working fine except only one  label is turning black cant figure out wnat the problem.

On clicking the check mark it is suppose to disable and turn black and only the first label is turning black. Here is the code and th DB

Private Sub Form_Current()
Dim i As Byte
    Dim sNum As String
    Dim isChecked As Boolean
   
    For i = 1 To 18
        sNum = Format(i, "00")
        isChecked = Me("chk" & sNum)
        Me("lbl" & sNum).BackColor = IIf(isChecked, vbBlack, vbWhite)
        Me("chk" & sNum).Enabled = Not isChecked
   
    Next
   
End Sub

Private Sub DisableMe(sCtrlName As String)

    sNum = Mid(sCtrlName, 4)
    Me("btn" & sNum).SetFocus
    Me("lbl" & sNum).BackColor = vbBlack
    Me(sCtrlName).Enabled = False

End Sub

Private Sub ResetMe(sCtrlName As String)
    Dim sNum As String
   
    sNum = Mid(sCtrlName, 4)
    Me("lbl" & sNum).BackColor = vbWhite
    Me("chk" & sNum).Enabled = True
    Me("chk" & sNum) = False

End Sub

Private Sub btn01_Click()
    ResetMe (ActiveControl.Name)
End Sub
Private Sub btn02_Click()
    ResetMe (ActiveControl.Name)
End Sub
Private Sub btn03_Click()
    ResetMe (ActiveControl.Name)
End Sub
Private Sub btn04_Click()
    ResetMe (ActiveControl.Name)
End Sub
Private Sub btn05_Click()
    ResetMe (ActiveControl.Name)
End Sub
Private Sub btn06_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn07_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn08_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn09_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn10_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn11_Click()
    ResetMe (ActiveControl.Name)
End Sub


Private Sub btn12_Click()
    ResetMe (ActiveControl.Name)
End Sub



Private Sub btn13_Click()
    ResetMe (ActiveControl.Name)
End Sub


Private Sub btn14_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn15_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn16_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn17_Click()
    ResetMe (ActiveControl.Name)
End Sub

Private Sub btn18_Click()
    ResetMe (ActiveControl.Name)
End Sub







Private Sub chk01_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk02_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk03_AfterUpdate()
    DisableMe (ActiveControl.Name)
End Sub
Private Sub chk04_AfterUpdate()
    DisableMe (ActiveControl.Name)
End Sub


Private Sub chk05_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk06_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk07_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk08_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk09_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub


Private Sub chk10_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk11_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk12_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk13_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk14_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk15_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk16_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk17_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub

Private Sub chk18_AfterUpdate()
DisableMe (ActiveControl.Name)
End Sub
bingo3.zip
gigifarrowAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hnasrConnect With a Mentor Commented:
In design mode, select label, and set Back Style to Normal.
0
 
IrogSintaConnect With a Mentor Commented:
Also you could make the code I gave you a bit better with this revision:
Private Sub DisableMe()
    Dim sCtrlName As String
    Dim sNum As String
 
    sCtrlName = ActiveControl.Name
    sNum = Mid(sCtrlName, 4)
    Me("btn" & sNum).SetFocus
    Me("lbl" & sNum).BackColor = vbBlack
    Me(sCtrlName).Enabled = False

End Sub

Private Sub ResetMe()
    Dim sCtrlName As String
    Dim sNum As String
    
    sCtrlName = ActiveControl.Name
    sNum = Mid(sCtrlName, 4)
    Me("lbl" & sNum).BackColor = vbWhite
    Me("chk" & sNum).Enabled = True
    Me("chk" & sNum) = False

End Sub

Open in new window

Then your other procedures would be shortened to this:
Private Sub btn01_Click()
    ResetMe
End Sub

Private Sub chk01_AfterUpdate()
    DisableMe
End Sub

Open in new window

0
 
clarkscottCommented:
Controls on tabular lists are not separate objects.  There are single objects that repeat for each record on the list.  With that said, you will have a hard time controlling certain objects on screen forms lists.

You can try Conditional Formatting for some of these controls.  This is a built-in feature of Access and can control certain formats for certain controls.

For example.... you can Lock a control on a tabular record based on other field values in the record... but you've actually locked the control on all the records... you just can't tell (or see it) because you're focused on the single record.  If you click to another record... it seems like that single control may be locked or not.   Now... if you try to control the source of a combo box in a single record.... each time you focus on another record... ALL the visible combos will change their record source.

You might want to figure out a different method for your visualizations.

Scott C
0
All Courses

From novice to tech pro — start learning today.