Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169

    Command button will not appear when I make a selection from a drop down

    Hey guys,

    Having a hell of a time trying to get a very simple function to work for a button. Works fine on all my other forms except this one. I have a button set to invisible by default and need it to appear only when one selection is selected from a drop down. I have tried every known combination I know of but it just will not work. This is the way I have it in my other forms, which works fine:

    If Me.SiteSelect = "Brandon, MB" Then
    Me.Dispatch2.Visible = True


    End If

    Any suggestions on what else I can do?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could do something like the following to see what the value of the combo is and to make sure the code is actually firing.

    Code:
    msgbox Me.SiteSelect
    If Me.SiteSelect = "Brandon, MB" Then
    Me.Dispatch2.Visible = True
    End If

  3. #3
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    It is definitely firing as I even tried using an Else statement where the opposite was true (making the button visible by default), and the button disappeared when I made the selection. I just will not appear when the button is invisible by default. Crazy!

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    There may be some corruption with one or more of the controls then.

  5. #5
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    Not sure where the corruption can be. Its a form with 2 fields, a combo box and one button. Very simple compared to my other more complex forms. I have even tried recreating the form from scratch.

  6. #6
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    This is what I use not sure by your description so thought I'd include it. has always worked for me.

    In the on Change event of the combo box (Or the After Update Event depends on if you allow the user to add new options If not then they must select one of the options there and the Change Event will work for you. If they are able to type in the combo box the on change event fires after each keystroke so that may not be the best option.)

    If combobox1.value = "Value I'm looking for"
    button1.visible = True
    Else
    button1.visible = False
    End if

  7. #7
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    No go, Ive tried that already as well too. : /

  8. #8
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    wait, I noticed you didnt include 'Me' at the front of you commands like I did. Is that not required?

  9. #9
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    I don't believe so the Me is the default it only really matters if your referencing a control on a different page.

  10. #10
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    ah ok, well I tried it and still no go. This bites!

  11. #11
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    There is one other possibility I can think of. It's bitten me once before. put a break point on the If Statement Then when the code window opens in the immediate window put in
    ?Me.siteselect = "Brandon, MB"

    See what the response is. If it's true then step through the code and see where the code is going awry. If it's not then do the following in the immediate window

    ?me.siteselect

    ?"Brandon, MB"

    That will give you both variables in an easy to compare format. It's possible that when you created the selection list an extra space creeped in there. Happened to me once. I typo'ed and hit the space bar by accident after putting a name in and couldn't get a match on that one name no matter how I tried. Took me forever to discover that the length of the strings I was comparing were 7 on one side and 8 on the other but looked exactly the same. Finally found the extra space on the end.

  12. #12
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Does it work if you are testing for a selection other than "Brandon, MB"? If it does, that suggests that the "Brandon, MB" value in the dropdown source isn't quite what you think it is (e.g. the blank isn't Chr(32), but is some other non-displayable character).

  13. #13
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    I have also tried that with the same results. The drop down however, I must add, is tied to table/query as the row source type. The row source is as follows: SELECT [Sites].[ID], [Sites].[Site], [Sites].[Address], [Sites].[Supported By] FROM Sites ORDER BY [Site]; ...Column count is 4, and column widths are 0";1.198";0";0" (not sure if that all makes a difference or not).

    The selection autopopulates the address field, and then is supposed to make the button appear.

  14. #14
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Does it correctly autopopulate the address field?
    What is the "bound column" set to?

    The way you have it shown, when you use me!siteselect, it is going to give you the Site ID, not its text value. If you want to reference and test the text value, you need to put me!siteselect.column(1) to reference the 2nd column, i.e. the one you see in the combo box. "Column(1)" is not a typo - the column reference is zero-based.

  15. #15
    tobydobo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    169
    The autopopulation portion works flawlessly:
    Me![Address] = Me.SiteSelect.Column(2)
    Me![AssignedTechs] = Me.SiteSelect.Column(3)

    I added the button command to the end of that like this:
    Private Sub SiteSelect_AfterUpdate()
    Me![Address] = Me.SiteSelect.Column(2)
    Me![AssignedTechs] = Me.SiteSelect.Column(3)
    If Me.SiteSelect = "Brandon, MB" Then
    Me.Dispatch2.Visible = True
    Else
    Me.Dispatch2.Visible = False
    End If

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-03-2015, 10:16 AM
  2. Replies: 2
    Last Post: 08-27-2014, 08:19 AM
  3. Replies: 5
    Last Post: 04-09-2014, 06:57 PM
  4. More Info" button based on Combo Box selection
    By kriskeven in forum Access
    Replies: 1
    Last Post: 05-21-2012, 02:23 PM
  5. Replies: 6
    Last Post: 03-10-2011, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums