"John Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:<(E-Mail Removed)>...
> On Fri, 16 Apr 2004 15:11:06 -0400, "Nathan C. Lee"
> <(E-Mail Removed)> wrote:
>
> >We're using Access '97 for this. I need to change the color of several
text
> >fields in a report.
>
> well... nitpick here, but one that may help. A Report has *controls*,
> not fields; each control may (or may not) be bound to a table field.
Ahh, thank you. I was in fact referring to TextBoxes and Labels. The
TextBoxes are getting their values from a table or a query.
> >1) My first question has to do with referencing the fields themselves. I
> >have 16 different fields, but for simplicity, I'm using a variable
> >"fieldBeingChanged" to reference them, and using a Select Case operation
to
> >select which field is being referenced. E.g.
> >
> >...
> >
> >Dim fieldBeingChanged As String
>
> I presume that these are the Name properties of Textbox controls on
> the form? If so...
> >...
> >
> >Case TRR
> >
> >fieldBeingChanged = "Report!StatusReport!TRRField"
>
> Dim fieldBeingChanged As Control
> Set fieldBeingChanged = Report!Statusreport.Controls("TRRField")
> fieldBeingChange.BackColor = vbRed
>
> <or whatever you want to do with the Control object)
Yes, fieldBeingChanged is meant to refer to the name of the TextBox
controls.
I've made the changes, but now I'm getting an error (Run-Time error 2465)
telling me
"Microsoft Access can't find the field 'StatusReport' referred to in your
expression."
I'm sure that I've spelled it right, and I do indeed have a report called
"StatusReport". Any idea what's going on here?
> >Is this the correct way to refer to the field? I'm a little unsure about
> >when to use quotes and when not.
>
> No. It's not. <g>
>
> >2) In the same Select Case, I need to reference two dates, valuePlan and
> >valueActual. The values in the database's table sometimes contain spaces,
> >for instance, the value is held as "TRR Plan". The code looks like this:
> >
> >Dim valuePlan As Date
> >
> >Dim valueActual As Date
> >
> >...
> >
> >Select Case currentPlace
>
> What is CurrentPlace? a String?
It's just an integer to keep track of steps of iteration. Based on the value
of CurrentPlace, the program chooses which of my TextBox or Label controls
to alter.
> >...
> >
> >Case TRR
>
> What is TRR? A String Variable? A string value which CurrentPlace
> might take (in which case you need Case "TRR")?
TRR is an enumerated integer value, working with CurrentPlace. If
CurrentPlace == TRR Then the program needs to alter TRRField. I don't think
I need quotes for that, do I?
> >...
> >
> >valuePlan = "Table!tblToolDatasheet!TRR Plan"
> >
> >valueActual = "Table!tblToolDatasheet!TRR Actual"
> >
> >I think I need quotes here, because the compiler yells at me because of
the
> >white space. Is this the correct way? It tells me that "Table" is
> >undefined... so how am I supposed to get something out of a table?
>
> By opening a Recordset, or using the DLookUp function:
>
> valuePlan = DLookUp("[TRR Plan]", "[tblToolDatasheet]", "<some
> criteria you don't specify to select which record in tblToolDatasheet
> you want to select>")
That makes sense. I shouldn't need to put in criteria if I don't need any
further filtering logic there, should I?
> >3) Finally, how should I actually change the color? I've tried
> >
> >fieldBeingChanged.BackColor = vbGreen
> >
> >but that's not working at all. The compiler highlights
"fieldBeingChanged"
> >and says "Invalid Qualifier". I'm guessing it thinks I'm trying to change
> >the BackColor on the string, but I really want to do it on the field the
> >string is referencing.
>
> Dim it as a Control as above.
Yes, I don't think it will give me trouble now that I am referring to the
controls correctly.
Thank you so much for your help.
> John W. Vinson[MVP]
> Come for live chats every Tuesday and Thursday
> http://go.compuserve.com/msdevapps?loc=us&access=public