I am creating a DB that tracks our monthly Bills/Expenses etc... The form itself has an input section for creating new items and assigning to appropriate pay period, then there is a Listbox section where you can select and edit that information. The problem I am having, is that I created little rectangle boxes that will switch between green and red () on_Click to denote when Item is paid/not paid. I want to set it up so that depending which "rectangle" I click on, will change focus to the appropriate list box row, then change between checked/not checked respectively with the color. Now, the real problem is that I don't want the rectangles to appear when there is no data in the respective list box row. I thought I figured it out, but it does the opposite of what I want, it makes all the boxes dissappear for the ones that have data... Im confused. I really hope this makes sense to you pros out there. And appreciate any help in advance. Here is the code for making the "rectangles" dissappear if no data is the list box.
Expand|Select|Wrap|Line Numbers
- Private Sub BoxCheck()
- Dim intI As Integer
- Dim intC As Integer
- C = Forms![BillExpUpdate].[lst1st_Bills].ListCount
- i = 0
- Do While i <> 17
- If i < C Then
- Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BorderStyle = Solid
- Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BackStyle = Normal
- Else
- Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BorderStyle = Transparent
- Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BackStyle = Transparent
- End If
- i = i + 1
- Loop
- End Function
Expand|Select|Wrap|Line Numbers
- Private Sub BoxCheck()
- Dim intI As Integer
- 'Sets focus to 1st Bill List Box and selects line 0.
- Me.lst1st_Bills.SetFocus
- Me.lst1st_Bills.ListIndex = 0
- 'If the 1st Bills "Paid" Box is Red, then will change to Green and set chkPaid value to "True"
- 'and refresh.
- If Me.BoxPaid0.BackColor = 255 Then
- Me.BoxPaid0.BackColor = 65280
- Me.chkPaid.SetFocus
- Me.chkPaid.Value = True
- Me.Refresh
- Else
- 'If the 1st Bills "Paid" Box is Green, then will change to Red and set chkPaid value to "False"
- 'and refresh.
- Me.BoxPaid0.BackColor = 255
- Me.chkPaid.SetFocus
- Me.chkPaid.Value = False
- Me.Refresh
- End If
- End Sub
[IMG]C:\Documents and Settings\Jeremy\Desktop\DBImage.bmp[/IMG]