Results 1 to 14 of 14
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    Combo box on click event

    What would be causing the on click event to not be functioning for a combo box. In my testing, I've put in a msgbox for the on click event, and nothing is happening.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The name of combobox was changed?

    The Click event property does not have [Event Procedure]?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    No haven't changed the name of the combobox.

    Can the on click event be used to create the dataset?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What do you mean 'create the dataset'? What do you want to happen in this procedure? Show code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I have two comboboxes on a form. When the user selects an item within combobox1, on the After Update event, it requeries combobox2. The row source within combobox2 is a query based on the selection made within combobox1. This is all working properly.

    What I'm trying to do is if the user clicks on combobox2 without making a selection from combobox1, a different query is used for the row source for combobox2.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Try the GotFocus event instead.

    Want to show your code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I've just been working on determining where I need to place the code. I haven't started on the code.

  8. #8
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    In the combobox2 got focus event
    if me.combo1 = "" then
    msgbox "run different query for data"
    end if

    This works.
    So I'm needing to use a different SQL statement for the row source. How do I change the row source when the condition is met in the above if statement?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If Me.combo1 & "" = "" Then
    Me.combo2.RowSource = "SELECT ...;"
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by crowegreg View Post
    What would be causing the on click event to not be functioning for a combo box. In my testing, I've put in a msgbox for the on click event, and nothing is happening.
    I suspect that the problem is that the OnClick event of a Combobox does not occur when you think it does! It occurs when you 'click' on a selection/item from the DropDown portion of the Control, not when you simply 'click' on the Control as you do when you go to drop it down! And this is why you cannot use the OnClick event for this purpose.

    Quote Originally Posted by crowegreg View Post

    ...What I'm trying to do is if the user clicks on combobox2 without making a selection from combobox1, a different query is used for the row source for combobox2.
    You could pull the switch, as June7 suggested, in the second Control's GotFocus event, or, if you don't want the thing firing off if the user simply passes thru the Combobox, on the way to another Control, rather than basing the Query used for the RowSource of Combobox2 on its OnClick event, have its RowSource set to this Query by Default. If nothing is selected from Combobox1, then the Combobox1_AfterUpdate event doesn't fire, and the Query remains the RowSource for #2.

    If, on the other hand, something is selected from Combobox1, the Combobox1_AfterUpdate event will fire, and the Query for the RowSource for #2 will be changed.

    Linq ;0)>.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thanks!! That is exactly what I was needing.

  12. #12
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thanks Missinglinq for the explanation. I couldn't figure out why the message box wasn't working on the on click. Now I know why.

  13. #13
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The OnClick event is one that often seems to defy logic, vis a vis how/when it fires! The OnClick event for a Tabbed Control Page, for instance, does not fire when you click on one of the Tabs at the top of the Pages, which would seem logical, but rather fires when you actually click on the 'background' of the Page, something I've never found a use for!

    Good luck with your project!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  14. #14
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Nothing like being logical, right?? Thanks for the additional research!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. List Box Click Event
    By bginhb in forum Forms
    Replies: 3
    Last Post: 04-09-2012, 02:06 PM
  2. On-Click Event Procedure
    By tbassngal in forum Forms
    Replies: 6
    Last Post: 07-20-2011, 07:06 AM
  3. On Click Event For Button On Form
    By Desstro in forum Forms
    Replies: 3
    Last Post: 08-09-2010, 02:36 PM
  4. On Click Event Procedure
    By MrDean in forum Forms
    Replies: 3
    Last Post: 10-07-2009, 07:16 AM
  5. On-Click event transfer
    By nkenney in forum Forms
    Replies: 16
    Last Post: 03-26-2009, 09:02 PM

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