code works in subform, but partially in headform (1 Viewer)

steven80

Registered User.
Local time
Today, 08:36
Joined
Jan 19, 2016
Messages
13
Hi,

I have a kalender-form where i have subforms to represent the days.

In the subform data is loaded and then the back color of a textfield in that sub is set depending on different values.

When i open the subform, everything works fine, but when i open the kalender form, only a part of the data gets colored.

When i hit the 'vandaag' button twice, or when i select a value in my combobox and then select that value for a second time it all works perfect.

in the subform i have the following code to color the textfields:

Code:
Private Sub details_paint()


Dim ROOD As Long
Dim Groen As Long
Dim Geel As Long
Dim GRIJS As Long
Dim LBL As Long
Dim BL As Long
Dim WIT As Long
Dim ZWART As Long
Dim KLEUR As Long

WIT = RGB(255, 255, 255)
ROOD = RGB(255, 127, 80)
Groen = RGB(0, 205, 0)
Geel = RGB(255, 215, 0)
LBL = RGB(99, 184, 255)
BL = RGB(202, 255, 255)
GRIJS = RGB(205, 197, 191)



If Optie = True Then
    KLEUR = GRIJS
Else
    Select Case CatID
        Case 1
            Select Case SubCatID
                Case 1
                KLEUR = LBL
                Case 2
                KLEUR = BL
                Case Else
                KLEUR = LBL
            End Select
        Case 2
        KLEUR = ROOD
        Case 3
        KLEUR = Groen
        Case 4
        KLEUR = Geel
        Case Else
        KLEUR = WIT
    End Select
End If

Me.Section(acDetail).Controls("txtnaam").BackColor = KLEUR

End Sub

The value of option, catid, and subcatid ar fields in my form to depend what color the field txtnaam should get.


if I load the subform i looks like this:

subform.jpg

When i load the calendar form, it loads al the data, but the color is not set everywhere.
kalendar form.jpg


Tnx for your help with this problem.

Steven
 
Last edited:

JHB

Have been here a while
Local time
Today, 17:36
Joined
Jun 17, 2012
Messages
7,732
The value of option, catid, and subcatid ar fields in my form to depend what color the field txtnaam should get.
Where do you declare the above or is it controls in your form, (if controls then use Me. in front of them, ex. Me.catid)?
Could you post your database with some sample data, zip it.
 

JHB

Have been here a while
Local time
Today, 17:36
Joined
Jun 17, 2012
Messages
7,732
I think the problem lay in, the paint in the subform, has already taken place before the form is ready to be shown on the screen, because the subform is loaded before the main form.
I've made a work around by setting a timer on the main form which is trigged when both forms is on the screen - you can try my solution, database is attached.
 

Attachments

  • Octopus - kopie.zip
    191.5 KB · Views: 104

steven80

Registered User.
Local time
Today, 08:36
Joined
Jan 19, 2016
Messages
13
JHB,
A simple but efficient solutions.

THANKS!

Steven
 

JHB

Have been here a while
Local time
Today, 17:36
Joined
Jun 17, 2012
Messages
7,732
You're welcome, good luck. :)
 

Users who are viewing this thread

Top Bottom