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

formatting text fields in continous form 1

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi,
In a continous form there are 3 text boxes, ID, firstanme, lastname.
The form is used to select clients, by ID. The selection works ok, but the question is this. In the condtional formatting I have used 'when the field has focus' and used this to change background colour and text, when the ID is selected.
What I would like to do is that when the ID field is selected that both the firstname and lastname has both the background colour and text the same as the ID field.

many thanks,

kp
 
how about an onchange event? Make the format of the ID (color and font) a variable an then pass that variable to the onchange event of the text boxes. Seems do-able. yes?

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Hi misscrf,
Many thanks for that reply. But I'm just not sure how to make that a variable and to pass that on to the other text boxes.

kp
 
can you share the code you have for formatting the ID combo? It might help for me to try to build what you are looking to do. Also the names of the controls of your text boxes that you are wanting to format the same, etc.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Seems do-able. yes?
No, absolutely not.

In is a continous form, you can not do this by code and only conditional formatting. Why? Because each control in a continous form is an instantiation of the same control. You change one and they all change.

In the conditional formatting, look at the first combobox
"Expression is"

Now what I do not understand is what you mean by the ID is selected. Do you mean when that record is selected? Is the ID set in a control on the header/footer?
 
opps. Sorry. Didn't realize that issue with the continuous forms in this situation.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Hi Majp,
When the cursor is put onto the ID field that field will change the background colour and font colour.
This then moves the main form to that clients details.

The ID, firstname, lastname fields are all set in the detail section of that subform.

Yes, I guess that's what I mean. That that record is selected on that form.
I guess just for ascetic looks, so that the whole record when selected has the same background and font colour. And when the user moves to the next record the former record will revert to the default formatting.
Many thanks

kp
 
I see what Tech is saying and what Maj is saying makes sense. If you change the format of a control, it is going to change that format for every record on the continuous form, because all records are displaying through that 1 control.

That is if I am understanding it right...

misscrf

It is never too late to become what you could have been ~ George Eliot
 
There are several versions of doing this. Check the FAQs. I like to put a hidden text box on my form because this allows me to debug it easier.

Form Module
Code:
Public Function prepIsSelected() As Boolean
  prepIsSelected = isSelected(Me, "EmployeeID", Me.EmployeeID)
End Function

Private Sub Form_Current()
  Me.Refresh
End Sub

Standard module
Code:
Public Function isSelected(frm As Access.Form, fldName As String, fldValue As Variant) As Boolean
  Dim rs As DAO.Recordset
  Set rs = frm.RecordsetClone
  rs.FindFirst "[" & fldName & "] =" & fldValue
  If rs.AbsolutePosition = frm.Recordset.AbsolutePosition Then
      isSelected = True
  End If
End Function

conditional formatting
Expression is : prepIsSelected()
 
I put the value of the text box to
=prepIsSelected()
Once I verify that the text box returns the correct value if the record is selected then I set the conditional formatting, then delete the text box.
 
Sorry. I remembered why I use the hidden text box, because there is a much simpler method. It is also much quicker

hidden textbox: txtSelected

form module:
Code:
Private Sub Form_Current()
  Me.txtSelected = Me.EmployeeID
End Sub

in the conditional formatting

ExpressionIs: [EmployeeID]=[txtSelected]

I confused this code with code to alternate color.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top