473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to make visibility one item dependent on choice of other

Hello, I have what seems like it should be a fairly simple question, but am having problems for whatever reason. In an Access form, I have two list boxes, [Status] and [PendTo]. In the [Status] box, I have the options "Open", "Pending", and "Closed"; with "PersonA" and "PersonB" in [PendTo]. What I would like to know is how to make it where the [PendTo] list box is only visible if the [Status] is set to "Pending". What I have is something like this in the BeforeUpdate field of the PendTo list box ('StatusLB' is the name of the [Status] list box itself):

=IIf("StatusLB='Pending'","Me!Visible=True","Me!Vi sible=False")

But alas, it doesn't work. Am I making a simple syntax error or is it even possible to do this, or am I just completely off? Please help.
Jul 16 '10 #1

✓ answered by missinglinq

To answer your question, you're just completely off! Sorry, but you asked!

Me.Visible controls the visibility of the entire form, not the PendTo listbox.

Also, any code in the PendTo_BeforeUpdate event won't fire until after something is selected from the PendTo listbox, so that isn't going to work for you, either.

Assuming that the listboxes are bound to fields in the underlying table/query, StatusLB has Multi-Select Property set to No and this is a Single View form, as opposed to a Datasheet or Continuous View form, this should do the job:
Expand|Select|Wrap|Line Numbers
  1. Private Sub StatusLB_AfterUpdate()
  2.  If Me.StatusLB = "Pending" Then
  3.   PendTo.Visible = True
  4.  Else
  5.   PendTo.Visible = False
  6.  End If
  7. End Sub
  8.  
  9. Private Sub Form_Current()
  10.  If Me.StatusLB = "Pending" Then
  11.   PendTo.Visible = True
  12.  Else
  13.   PendTo.Visible = False
  14.  End If
  15. End Sub
Welcome to Bytes!

Linq ;0)>

4 1676
missinglinq
3,532 Expert 2GB
To answer your question, you're just completely off! Sorry, but you asked!

Me.Visible controls the visibility of the entire form, not the PendTo listbox.

Also, any code in the PendTo_BeforeUpdate event won't fire until after something is selected from the PendTo listbox, so that isn't going to work for you, either.

Assuming that the listboxes are bound to fields in the underlying table/query, StatusLB has Multi-Select Property set to No and this is a Single View form, as opposed to a Datasheet or Continuous View form, this should do the job:
Expand|Select|Wrap|Line Numbers
  1. Private Sub StatusLB_AfterUpdate()
  2.  If Me.StatusLB = "Pending" Then
  3.   PendTo.Visible = True
  4.  Else
  5.   PendTo.Visible = False
  6.  End If
  7. End Sub
  8.  
  9. Private Sub Form_Current()
  10.  If Me.StatusLB = "Pending" Then
  11.   PendTo.Visible = True
  12.  Else
  13.   PendTo.Visible = False
  14.  End If
  15. End Sub
Welcome to Bytes!

Linq ;0)>
Jul 16 '10 #2
It works! Oh thank you so much. I actually tried something close to each of those two subs at one point, but never thought of using them both together. It makes sense why you have to do it that way though. Thanks again.
Jul 16 '10 #3
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Jul 19 '10 #4
NeoPa
32,556 Expert Mod 16PB
Just as an alternative (as I know Linq's code should work) I'll post :
Expand|Select|Wrap|Line Numbers
  1. Private Sub StatusLB_AfterUpdate()
  2.   Call PendToVis()
  3. End Sub
  4.  
  5. Private Sub Form_Current()
  6.   Call PendToVis()
  7. End Sub
  8.  
  9. Private PendToVis()
  10.   Me.PendTo.Visible = (Me.StatusLB = "Pending")
  11. End Sub
I always recommend taking common code out into its own procedure, as an aide to avoiding potential problems later (if anything needs to be changed).

This is purely for the benefit of the OP as I know you wouldn't need to be told this Linq ;)
Jul 20 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bart Lateur | last post by:
In an Access form, I'd like to show the status on whether an item as entered in a textbox (and thus in its coupled record field) exists in a list in another table. I've tried: - Making the...
1
by: Shannan Casteel via AccessMonster.com | last post by:
I want to have a form with 40 PartNumber text boxes, 40 PartDescription text boxes, and 40 PartPrice text boxes. The name of each would vary of course, but I want to be able to enter the part...
7
by: djc | last post by:
I have several subroutines (all inline code) that wind up using the same database connection object variable. I have been declaring a new variable in every sub. I just now came to a point where I...
5
by: lukster | last post by:
Hello There, I'm trying to create a view that has calculations dependent on calculations, where the problem resides is that each time I make a calculation I must create an intermediate view so I...
0
by: Dst | last post by:
How can i make the selecteditem in a gridview visible ? I have a gridview inside a panel which has a vertical scrollbar. Is it possible to make it visible ? Scroll down or something...
0
by: imranafsari | last post by:
Dear All, I am making web based application using asp.net and C#(VS2005) . i have two questionn 1. how i can access menu item seleted in other web page using C#. 2.Based on the value in the text...
1
by: imran | last post by:
Dear All, I am developing web Application using asp.net and C#(VS2005).i want to know how i can fetch menu item selected(which is desinged in master.aspx) on the other C# page (welcome.aspx.cs).
0
by: sony.m.2007 | last post by:
Hi, I'm creating a combox control in XAML(WPF) and loading the items from a table in sql server. There are four items in the combobox.I need to hide an item in the combobox and to show three...
31
by: WannabePrgmr | last post by:
I am working in Access 2003 and have approximately 10 fields that I want to be able to query on. The catch is that if I only fill in 3 or 4 fields, only the data that matches only those three fields...
1
by: amel86 | last post by:
hello everybody, i have a problem in my system related to list menu dependent. i want a simple list menu dependent that when we select A, it show B, when select B it show C and so on. If...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.