A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Make subform visible when a field has a particular value



 
 
Thread Tools Display Modes
  #11  
Old December 2nd, 2009, 12:41 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Make subform visible when a field has a particular value

To expand a little on what Gina wrote, you need both expressions at once:

If Me.[YourField] = "Y" Then
Me.[NameOfSubformControl].Visible = True
Else
Me.[NameOfSubformControl].Visible = False
End If

To simplify the expression, maybe something like:
Me.[NameOfSubformControl].Visible = (Me.[YourField] = "Y")

Since (Me.[YourField] = "Y") evaluates either to True or False, it takes the
place of the word True or False in the expression. One line of code covers
both possibilites. This assumes there are just two possibilites for
YourField.

To place the code in the text box After Update event, in form design view
click the text box to select it, then click View Properties. This will
display the Property Sheet (if it was not already displayed), with tabs for
Format, Data, Event, Other, and All. Click the Event tab, click After Update,
click Code Builder OK. This will open the VBA editor, with Private Sub
and End Sub lines. Place the code between the two. Same for the form's
Current event. To switch to the Property Sheet for the form, click the
little square on the top left where the rulers meet in design view (if the
Property Sheet is displayed). If it is not displayed, double click that
little square, or click it once and click View Properties.

In any case, the Property Sheet title bar will tell you what properties you
are seeing.

JJ1109 wrote:
Thanks Jeanette,

So in the subform I need the same field that's the master field in the main
form, to be the child?

How do I write the expression to make the subform be visible or not? I have
no idea how to write them

thanks again
JJ

Use the link master field and link child field to link the subform to the
main form.

[quoted text clipped - 16 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200912/1

  #12  
Old December 2nd, 2009, 12:41 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Make subform visible when a field has a particular value

To expand a little on what Gina wrote, you need both expressions at once:

If Me.[YourField] = "Y" Then
Me.[NameOfSubformControl].Visible = True
Else
Me.[NameOfSubformControl].Visible = False
End If

To simplify the expression, maybe something like:
Me.[NameOfSubformControl].Visible = (Me.[YourField] = "Y")

Since (Me.[YourField] = "Y") evaluates either to True or False, it takes the
place of the word True or False in the expression. One line of code covers
both possibilites. This assumes there are just two possibilites for
YourField.

To place the code in the text box After Update event, in form design view
click the text box to select it, then click View Properties. This will
display the Property Sheet (if it was not already displayed), with tabs for
Format, Data, Event, Other, and All. Click the Event tab, click After Update,
click Code Builder OK. This will open the VBA editor, with Private Sub
and End Sub lines. Place the code between the two. Same for the form's
Current event. To switch to the Property Sheet for the form, click the
little square on the top left where the rulers meet in design view (if the
Property Sheet is displayed). If it is not displayed, double click that
little square, or click it once and click View Properties.

In any case, the Property Sheet title bar will tell you what properties you
are seeing.

JJ1109 wrote:
Thanks Jeanette,

So in the subform I need the same field that's the master field in the main
form, to be the child?

How do I write the expression to make the subform be visible or not? I have
no idea how to write them

thanks again
JJ

Use the link master field and link child field to link the subform to the
main form.

[quoted text clipped - 16 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200912/1

  #13  
Old December 2nd, 2009, 12:41 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Make subform visible when a field has a particular value

To expand a little on what Gina wrote, you need both expressions at once:

If Me.[YourField] = "Y" Then
Me.[NameOfSubformControl].Visible = True
Else
Me.[NameOfSubformControl].Visible = False
End If

To simplify the expression, maybe something like:
Me.[NameOfSubformControl].Visible = (Me.[YourField] = "Y")

Since (Me.[YourField] = "Y") evaluates either to True or False, it takes the
place of the word True or False in the expression. One line of code covers
both possibilites. This assumes there are just two possibilites for
YourField.

To place the code in the text box After Update event, in form design view
click the text box to select it, then click View Properties. This will
display the Property Sheet (if it was not already displayed), with tabs for
Format, Data, Event, Other, and All. Click the Event tab, click After Update,
click Code Builder OK. This will open the VBA editor, with Private Sub
and End Sub lines. Place the code between the two. Same for the form's
Current event. To switch to the Property Sheet for the form, click the
little square on the top left where the rulers meet in design view (if the
Property Sheet is displayed). If it is not displayed, double click that
little square, or click it once and click View Properties.

In any case, the Property Sheet title bar will tell you what properties you
are seeing.

JJ1109 wrote:
Thanks Jeanette,

So in the subform I need the same field that's the master field in the main
form, to be the child?

How do I write the expression to make the subform be visible or not? I have
no idea how to write them

thanks again
JJ

Use the link master field and link child field to link the subform to the
main form.

[quoted text clipped - 16 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200912/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.