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

Formatting Continous Forms

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
I have a continous form that I want to change the fore color for each individual record based on the value of a control in that record.

Any ideas of how to do this will be greatly appreciated.


Thanks,

Kopy
 
Hi,

I have wanted to do something like this in the past, but never found a way of doing it, if you find out let me know.
 
If your form is in Continuous View then in the Current Event for the form you should be able to put code that says
If Me.TextboxName = "SomeValue" Then
Me.Field1.ForeColor = vbBlue
Me.Field2.ForeColor = vbRed
.
.
.
Me.Fieldn.ForeColor = vbGreen
End If

That's all it should take.

Paul
 
You might want to checkout the Conditional Formatting option on the format menu. If you want to change the entire record, select each textbox, and choose Conditional Formatting. For the condition, choose "Expression Is" and enter a boolean expression in the box to the right. Such as UCase(Left([txtName],1))>"M" if you had a control named txtName. The would set the formatting if left character of txtName was greater than M (I know...stupid example). But it does add overhead to the screen performance. Maybe if the expression used a field from your underlying query may speed it up a bit.
 
The technique you describe with using conditional entries works fine. However, is there a way to change one of the other attributes of a field conditionally. For example, could I disallow a field to be updated based on a conditional entry?

Thanks,

John Harkins
 
On the Current event of the form, like Pauls example:

If Me.TextboxName = "SomeValue" Then
Me.TextboxField1.Locked = True
Else
Me.TextboxField1.Locked = False
End If
 
Ah, but wouldn't that disallow the field for _all_ records in the continuous form?

For the time being, the "enable" feature will work just fine.

Thanks!

John Harkins
 
Technically...Yes. But the Current event fires everytime user changes records, so in essence it would lock or unlock the record user is currently editing.
 
i have a similar issue trying to get the backcolor of a text box to change based on the value in another field.

What i am trying to do is allow the user to pick a color to associate it with a specific record.

i can pop up the Color window and get the long value that represents the color and store that with the record no problem.

Using the 'on current' event i can get the backcoor of my text box to display... but that changes the backcolor of all instances of the text box, where as i need each one to be a different color.

Any ideas what i can do...
it seems a shame there is no onformat event like on reports that i can use!
 
Did you ever find an answer to this
I am trying to do the same thing
Field1 on record 1 green because value is greater than 0
Field1 on record 5 red because value is negative

Thanks,
John McKenney
Work Hard... Play Harder
 
John, you should be able to use the Conditional Formatting that sfm6s524 speaks of in their first post. If that doesn't work, you may not be able to do what you want. Continuous forms work the same way a single view form does but the difference is you can see all the records. The record you are working in (that has the focus), is the one that will dictate what the formatting looks like in the rest of the records. The Conditional Formatting is designed to specifically address some, BUT NOT ALL, of the issues with this.
Good luck.

Paul
 
You might want to check out thread702-661512. You may get some ideas from that. Bill Power's example worked for me. I think he has one on one of his link's in the post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top