Full Version: Textbox visibility using IIF
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Vongalin
I have an unbound textbox in the my Form Header (named txtCurrentRecord). In my Current event for the form I have this : Me.txtCurrentRecord.Value = Me.ID and the current record's ID is displayed in the box.

I also have a textbox that is "sent to the back", Visible=False, Enabled=False, Locked=True and has a light gray background that covers the record. Note that is unbound on a continuous form, so any attempt I try to make visible/invisible applies to every record.

If I use something like this in the txtBackground Control Source : =IIf([ID]=[txtCurrentRecord],-1,0) is displays -1 in the current record and 0 for the rest of them on the form.

I am trying to get something like this to work : =IIf([ID]=[txtCurrentRecord], [txtBackground].Visible =True, [txtBackground].Visible =False), but it doesn't appear to work w/properties, only text.

I know the problems with unbound controls on continuous forms, and I don't have anything in the recordsource that would allow me to query on to determine if it's current or not or highlight for some other reason.

Is there any workaround to simply "highlight" the current record when using a continuous form ?
fkegley
This link may be able to help you do what you are trying to do:

conditional formatting
pere_de_chipstick
Hi Vongalin

I use the following:
1. Put a text box in the header or footer bound to the ID field, call it (e.g.) HeadID
2. Create a new text box inthe details section
2a set the font to wingdings
2b set the Control Source to =IIF(Me![ID] = Me![HeadID],"ü")
2c Set the font forecolour to 255
2d Set the Enabled property to No
2e Set the locked property to Yes

The text box will show a red 'tick' on the selected row

HTH
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.