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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditonal formatting using code

Status
Not open for further replies.

rmork

Technical User
Nov 15, 2006
36
NO
I'm trying to help a friend with his database containing ships, persons, projects, dockyards a.s.f..
He wants to format all the ship names in i subform that has active projects (the boat is in dock) formatted in red and bold

Is it possible to make tekst in a continues sub form red and bold if this code is met:

Function funcVesselsHasActiveProject(VesselID As Long) As Boolean

funcVesselsHasActiveProject = DCount("AVD01ProjectID", "AVD01Projects", "VesselID = " + CStr(VesselID) + " AND " + _
"ClosedDate IS NULL")

End Function

I am aware of the option "conditional formatting" under the format menu, but I'm not a programmer, and my knowledge is limited. Have tryed everything, but no luck so far...
Anyone??
 
With a continuous subform - such code - no!

This is more a question for the forms forum (forum702), but think of a control seen through all the rows you get in a continuous form - it doesn't represent different controls per each row, but multiple instances of the same control - change one, you'll change all the instances of it - so in a form, you're stuck with regular conditional formatting, or you could try some of the stuff that's supposed to work in previous versions
Try the conditional formatting thingie, remember that you need to enclose control/field names in [brackets]. Select the controls you wish to apply this to, then in the Conditional Formatting thingie, choose "Expression is", then perhaps try the following expression [ClosedDate] Is Null, apply the wished format (bold and red)

Roy-Vidar
 
Thanks for a quick replay! :)
The next step is to get this to work in the report as well, but the priority was the form. Forgot to mention that the closed date control is not on the mainform or on any of the subform. It has to get it from another form. Is that a problem regarding this? Or does that just mean that the expression would be something like:
[forms].[SomeForm].[closedDate]Is Null

Have been looking around for some time in this forum now. but cannot find anything that fits me, or that I can understand. I have no knowledge of VBA... Yet :)

I will post this in 702 as well...
Maybe I can get the report to do it right...
Thanks again...
 
I see now that I posted in the wrong group, but If someone can help with this in a report as well, feel free..
 
I need the help in the report. I have a combo box called Status and depending on the status, I need to highlight using green, yellow, or red. This is a typical red light/green light report.

I've got it working on the form, just need to figure out how to get the report to do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top