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

Hiding/Showing Fields

Status
Not open for further replies.

SSJpn

Technical User
Oct 7, 2002
259
0
0
US
I have a few fields (textboxes, combo boxes) that are not visible on the form. Now depending on the value of another field I want the hidden fields to either be shown or stay invisible.

Ive added an 'After Update' code that checks the value in a field and either makes visible or keeps hidden the other fields. However, when it makes the fields visible it does so for ALL records instead of just the current record. How can I make it so that it only makes visible the field on the current record?
 
Hi :)

The best thing is to perform value checks again on Current Event of the form and set the fields visible or invisible. I will suggest that make a function for checking values and changing the propoerties of controls and than call this function on After Update event of the controls and On Current Event of the form.

Good Luck Cheers!
ÙÇãá
 
You need to force the afterupdate event when the user change to another record:

Private Sub Form_Current()
fieldx_AfterUpdate
End Sub

The afterupdate event ocurs only when the user changes the value (type something) of the field.


 
I guess that would work, but that just seems like a way 'around' the problem. Isn't there a way to control the visible property of a field for EACH record.

For example FieldX is visible on recordset 1 but hidden on recordset 2, visible from recordsets 3-5, hidden on 6 etc etc....

I need it like that because the additional fields do not make sense to have unless my condition is true. My conditional field is "are additional monies due?" and IF there is THEN "have the additional monies been sent?." It doesnt make sense to have the latter field unless the first field is true.
 
I put the code in the CurrentEvent but i get a run-time error saying that I cannot reference the properties of the field unless it has focus.

What now?
 
Hi :)

Which propoerties u r referring to. I know for sure that the Visible propoerty doesnot require Focus. Can u post the code?

Cheers!
ÙÇãá
 
Im trying to manipulate the Font.Bold property of textboxes.
to make the text bold if a condition is met


Sub Current Event()
If blah blah blah Then
FieldX.FontBold = 1
Else
FieldX.FontBold = 0
End I
 
Hi,
I have similiar problem here. Is it possible to hide the combo box based on value of each record in continuos form. When I set visible to false in form current, it end up all the combox box in all records is hidden. Please help!
 
I don't believe it's possible in Access to do what you want. The reason is, there is only one instance of the form and the state of the controls in the form in memory. The only way to perform what you are asking would be by using an array of forms. This seems an expensive approach. If such a feature is critical for your app, perhaps you may want to try to implement the solution in Excel, which gives you cell level control.
 
That's so weird because I think I've seen similar things before when I did some data entry. The form had hidden fields that would appear when certain radio buttons were selected. Then when I moved to the next record.. the form "reset" and all the hidden fields were hidden again. When I would scroll through the records all the fields would be hidden/visible appropriately depending on how the other fields were filled in. I wan't something like this, only instead of visible/hidden i want bold/unbold.
 
SSJ,

I agree with Aqif . . .you can't really test for each record per se, you have to test at various event points and then set the font based on each of those test. Coding the After Update and Current should get most conditions, but you may need to test all possible uses of your form to make sure that you have put the code in the proper events.

It is not uncommon on a complicated form to post the same code to several events to make sure that whatever you are trying to control behaves properly in all situations. - - - -

Bryan
 
The code that I have in the afterupdate/change events work well to assure that the properties for my fields for the record that is currently being entered are correct.

However I need to be able to scroll/peruse through my set of records that have already been entered and have my properties be set correctly. In the case that the records have already been entered it doesnt do any good to have the code in the afterupdate/change events because nothing is being updated in the field (im simply scrolling through my records). Therefor the CurrentEvent event seemed promising since it would run the code everytime I viewed a different record? But I guess you can't change the bold property of a field from within the even procedure.

Is there another event that I could use that would run every time I 'scroll' through my records?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top