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

Is there a "On format"-alike event for forms?

Status
Not open for further replies.

dirkg

Technical User
May 20, 2000
170
BE
Hi all,<br><br>On reports one can use the on format-event to change the format of a control for each record depending on a value in a field in that certain record.<br><br>I would like to do the same thing with a form. Does anyone know how to do this?<br><br>More specific I want this:<br><br>there is one field in my underlying table which is called CRITERIUM. For certain criteria there is also a description available in the field DESCR. What I want is that, when ther is no description in DESCR, the field where normally the value of DESCR comes in, is not visible in the form and so this can differ from record to record; Does anyone has a clue?<br><br>Thank you very much in advance!<br><br>Greetings,<br><br>Dirk<br><br><A HREF="mailto:dirk.news@yucom.be">dirk.news@yucom.be</A>
 
In the On_current event of the form do this<br><br>Private Sub Form_Current()<br>&nbsp;&nbsp;&nbsp;&nbsp;If IsNull(Me!DESCR) Or Me!DESCR = &quot;&quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me!DESCR.Visible = False<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me!DESCR.Visible = True<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End Sub<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
You would also want to add the same code to the After Update event of the field too, in case you change the value and want it to recognize that change while you remain on the current record.
 
Thanks for your answers but this doesn't solve my problem since the ON_CURRENT action changes the setting for all the records so the textbox will become (in)visible in all the records. What I'm looking for is making the textbox visible or invisible for each record seperatly. This doesn't have to change while the form is open since the user can't change the values that determine whether the textbox has to be visible or not. <br><br>Greetings,<br><br><br>Dirk
 
On a single-record form the field would seem to be visible or invisible each time you looked at a new record. On a continuous form, the filed would be visible or invidible depending on the record selected. In other words, that field would blink on and off as you moved from record to record, fepending on it's value.
 
I think this depends on how your fields are setup in your table.&nbsp;&nbsp;I ran a test with the two fields you described and came up with this:<br><br>table: Criterium field - as a lookup field in which you type the values you want to choose from.&nbsp;&nbsp;As an example I chose 1.Good 2.Bad 3.Neutral<br><br>the Descr field should be setup as a text field with no formatting in the table.<br><br>Then when you create the form, you go to the form's &quot;on Current&quot; event and type this:<br>(remember, all words in parentheses are not part of code)<br><br>Private Sub Form_Current<br>Select Case [Criterium] (based on value in this field)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;Bad&quot; (if the Criterium field says &quot;Bad&quot; then)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Descr] = &quot;whatever your descr is&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;Good&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Descr] = &quot;whatever Good's descr is&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;Neutral&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Descr] = &quot;&quot; (this one has no description)<br>End Select <br><br>(now you have programmed the descriptions to match the criteria, next you will match the criteria without descr's to &quot;not visible&quot; state for descr field)<br><br>Select Case [criterium]<br>Case &quot;Neutral&quot;<br>me.descr.visible = false<br>case else<br>me.cescr.visible = true <br>end select<br>(the second to last line says all criteria not listed above will make the descr field visible)<br>
 
Indeed Elisabeth, I forgot to mention that I want to hide and show the text-field in the records on a continuous form....
 
Indeed Elisabeth, I forgot to mention that I want to hide and show the text-field in the records on a continuous form....I guess this is impossible right? :-(
 
There was a similar question a day or two ago about changing the backcolor on a continuous form for a given row. <br><br>This <b>cannot</b> be done, as when you change any property of a field (color, visible, enabled, whatever), it does it for the same field on every record.<br><br>Try it, and you will see what I am talking about. I know of no code that will allow this to happen, if someone does, please fill me in. <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top