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  dBforums > PC based Database Applications > Microsoft Access > I want to make a field visible based on the combo box selection

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 15
I want to make a field visible based on the combo box selection

Hello,
I am using MS Access 2010.
I have a field that is invisible.
I want to make it visible based on the selection from a combo box.
There are more than one possible selections that would make this visible.
Here is the breakdown.
I have an inventory form that lists the cost and retail price of an item
When I select the "Location" of the item (where it is being sold, ie: Betty's Bargain Barn) I want a heading that says Consignment to appear as well as the Price.
There are other locations that can make this consignment heading and price field appear, so it would need to have more than one "IF" in it.
I am new to this so I am guessing. I tried to create the code but it won't show up.
Thanks in advance for reading this and hopefully someone can help.
Have a good one!
Reply With Quote
  #2 (permalink)  
Old
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,273
In the after update in the combobox

Add me.textboxname.visible = true
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 15
Thank you but it didn't work. It comes up with an error.
Out of a list of five, I only want three to make the consignment fields visible.
Reply With Quote
  #4 (permalink)  
Old
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,273
What was the error

You have to put if then if you want it to show in differance values
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 15
thanks, I did get it to work. I am new at this and got confused.
I did try to enter the if statement for all three choices, but only one seems to work.
Again, so new to this. Sorry if I am coming off as stupid.

I appreciate all the help!!
Reply With Quote
  #6 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,406
First you say you want a 'heading' that says 'Consignment' to appear, then you say you want to make the 'consignment fields' visible. Which is it?
  • A 'heading,' i.e. a Label that you want to say "Consignment?" ?
  • A Textbox that you want to have "Consignment" as a Value?
  • Do you want the Price Textbox to always appear, or only if Consignment is displayed?
Also, is this a Single View Form, i.e. one only showing one Record at a time?

Linq ;0)>
__________________
Hope this helps!

The Devil's in the Details!!

All posts/responses based on Access 2003/2007
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 15
here is the info:
simple form
want to be able to select a location from the drop down box and have the following appear:
Consignment label
Consignment Price (a $ value)

There is more than one location that will make this happen.

I only mentioned the label first because once I got this to work, I would add the rest.
Reply With Quote
  #8 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,406
This example should help. You'll need to substitue your own names, of course:
Code:
Private Sub LocationCombobx_AfterUpdate()

Select Case Me.LocationCombobx
  Case "Betty's Bargain Barn", "Joe's Junk and Java", "Sam's Swap Shop"
    Heading.Visible = True
  Case Else
    Heading.Visible = False
  End Select
   
End Sub
Code:
Private Sub Form_Current()

Select Case Me.LocationCombobx
  Case "Betty's Bargain Barn", "Joe's Junk and Java", "Sam's Swap Shop"
    Heading.Visible = True
  Case Else
    Heading.Visible = False
  End Select
 
End Sub
Linq ;0)>
__________________
Hope this helps!

The Devil's in the Details!!

All posts/responses based on Access 2003/2007
Reply With Quote
  #9 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 15
AWESOME!!
Thank you! It works!

As I am now doing this, I realize I will have to update the cases (ie: Betty's Bargain Barn, etc) in the macro everytime I add a new location that qualifies.
Can I select the cases from a form or a query automatically? So basically when I add a new location, I will not have to update the macro with the new name.
Reply With Quote
  #10 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,406
Not unless the 'Consignment' facilities are kept in a separate Table from the other facilities, and from what we have, so far, that doesn't sound appropriate. To do have Access automatically know, when you added a new facility, whether it was 'Consignment' or not, you'd have to a have a Field, perhaps a Yes/No Field, with a Checkbox on the Form, to indicate that the particular Location qualifies as a 'Consignment' facility. You'd then base your Visible/Invisible formatting off the whether or not the Checkbox was ticked, rather than the name of the place.

Linq ;0)>
__________________
Hope this helps!

The Devil's in the Details!!

All posts/responses based on Access 2003/2007
Reply With Quote
  #11 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 15
Genius!!
It worked, thank you so much!!
I really appreciate you taking the time to help me out and being patient.
Your idea worked perfectly!!

Have a great day!!!
Reply With Quote
  #12 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,406
Glad we could help!

Good luck on your project!

Linq ;0)>
__________________
Hope this helps!

The Devil's in the Details!!

All posts/responses based on Access 2003/2007
Reply With Quote
  #13 (permalink)  
Old
Registered User
 
Join Date: Jul 2013
Posts: 2
I just had a quick question on this same subject. This is my code:

Private Sub Console_AfterUpdate()
If Me.Console.Value = 2 Then
Me.A_P_M.Visible = True
Else
Me.A_P_M.Visible = False
End If
End Sub

Essentially what this does, is depending on what I select from the "Console" combo box, the "A_P_M" combo box will be visible or not. This code does work, but just with one problem.
When I switch between records in the form that has this code, each record doesn't update to reflect what has been selected in "Console". For example, If I select console value 2 (visible A_P_M) in Record A, and then go to Record C, regardless of what is selected in Record C, the A_P_M will also be visible.

My question - how do I get each record to refresh/requery so it reflects that particular form's data?
Reply With Quote
  #14 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,406
To be Record-appropriate, moving from Record-to-Record, you have to have the same code in the Form_Current event, as well as in the Console_AfterUpdate event.

Linq ;0)>
__________________
Hope this helps!

The Devil's in the Details!!

All posts/responses based on Access 2003/2007
Reply With Quote
  #15 (permalink)  
Old
Registered User
 
Join Date: Jul 2013
Posts: 2
Beautiful, worked perfectly, thanks so much!
Reply With Quote
Reply

Tags
combo box, selection, visible

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On