Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Form Attributes

Status
Not open for further replies.

Russie

Programmer
Dec 24, 2000
104
US
Hi.

I have a form that is referenced by the RiskID ID variable when it boots. Some of the form header information is generated by using DLookup's.

I have 2 indicators on my form that I would like to change the background attributes when the form loads. The attribute will depend on a value that is derived through the use of a field DLookup.

At present I can't get my code to work because putting it on the 'On-Load' of the form means that it's executed before the DLookup variable has had time to resolve.

How would I be able to overcome this. I need some code to run straight after a DLookup field has received data but so far I haven't had any success.

Thanks for anything.

Russie
 
How are ya Russie . . . . .

[blue] I can't get my code to work because putting it on the 'On-Load' of the form means that it's executed before the [purple]DLookup variable[/purple] has had time to resolve.[/blue]
It appears this [purple]DLookup variable[/b][purple] is more that likely a part of the [blue]Criteria[/blue] and involved in a calculation of sorts (no other reason for having to waiting).

Be more specific about this [purple]DLookup variable[/b][purple] and its role in your form.

If you can, post your current code for this . . .



Calvin.gif
See Ya! . . . . . .
 
This code isn't rocket science:

Private Sub Form_Load()

Dim varIndicator

'assign RiskID to risk number field
Me.txtRiskID = varRiskNumber

varIndicator = DLookup("[RiskIndicator]", "tblInitialRiskAssessment", "[RiskID] = '" & varRiskNumber & "'")

Select Case varIndicator

Case "LOW"
Me.boxRiskIndicator.BackColor = vbGreen
Me.boxRiskScoreIndicator.BackColor = vbGreen
DoEvents

Case "MODERATE"
Me.boxRiskIndicator.BackColor = vbYellow
Me.boxRiskScoreIndicator.BackColor = vbYellow
DoEvents

Case "HIGH"
Me.boxRiskIndicator.BackColor = 4227327
Me.boxRiskScoreIndicator.BackColor = 4227327
DoEvents

Case "EXTREME"
Me.boxRiskIndicator.BackColor = vbRed
Me.boxRiskScoreIndicator.BackColor = vbRed
DoEvents

End Select

The code runs OK, I've tested and it is correct with one small problem. The color attributes don't change, if I go into design mode and back into form mode it works but it doesn't work when the form loads.

Do you know why this is?

Thanks.
 
Russie . . . . .

I've run a simulation using [blue]Access 2000[/blue] and no problemo. As for explaining it, I've never had this problem and have used this technique in other databases (specifically using the On Load event).

Out of curiosity where is [blue]varRiskNumber[/blue] getting its value from?

Anyway, try [purple]Me.Refresh[/purple] after [blue]End Select[/blue] . . . . .



Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top