Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Apr 2012
    Posts
    20

    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!

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,275
    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

  3. #3
    Join Date
    Apr 2012
    Posts
    20
    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.

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,275
    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

  5. #5
    Join Date
    Apr 2012
    Posts
    20
    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!!

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,570
    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

  7. #7
    Join Date
    Apr 2012
    Posts
    20
    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.

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,570
    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

  9. #9
    Join Date
    Apr 2012
    Posts
    20
    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.

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,570
    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

  11. #11
    Join Date
    Apr 2012
    Posts
    20
    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!!!

  12. #12
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,570
    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

  13. #13
    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?

  14. #14
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,570
    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

  15. #15
    Join Date
    Jul 2013
    Posts
    2
    Beautiful, worked perfectly, thanks so much!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •