formatting question

  • Thread starter Thread starter Stjepan Derek
  • Start date Start date
S

Stjepan Derek

I would like to set some format properties for a bound textbox using VBA (or
??). My question is : is it possible to run vb function that check textbox
value for each record and then set property for it.

I don't think that this is possible so I thought to solve this by doing
function that exports html. For each record of my recordset I can check
value and produce html string. Something like this:



If myValueInReccordSet="John" than MyHtmlString="<font color=red>" +
myValueInReccordSet + "</font>"
 
You might be able to do this without code/vba by using conditional
formatting. You can also use code in the On Format event of the section
containing the control:
If Me.txtFirstName = "John" Then
Me.txtFirstName.ForeColor = vbRed
Else
Me.txtFirstName.ForeColor = vbBlack
End If
 
This is not good answer because:

If I have a bound textbox with this condition:

If Me.firstName = "john" Then Me.firstName.ForeColor = vbRed

and let say that datasource for my report has 3 records with values "steve"
"john" "mary" - in report every record will be in red color.

Conditional formatting is good for simple things but if I try to do
something more complex it's no good.

My question is: is there event that occurs before each record of data source
is printed on report? Is it possible to change properties for bound textbox
control but for each printed record (in design view there is only one
textbox control - on preview there are more values)
 
You can use code in the On Format event of the report section containing the
control. Make sure the code sets the forecolor back to vbBlack.
If Me.FirstName = "john" Then
Me.FirstName.ForeColor = vbRed
Else
Me.FirstName.ForeColor = vbBlack
End If
 
Back
Top