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.
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.
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.
No haven't changed the name of the combobox.
Can the on click event be used to create the dataset?
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.
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.
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.
I've just been working on determining where I need to place the code. I haven't started on the code.
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?
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.
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.
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
Thanks!! That is exactly what I was needing.
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.
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
Nothing like being logical, right?? Thanks for the additional research!!