I have several cascading ComboBoxes & would like to close Cbo2 & open Cbo1
when there is an error. These CboBoxes are on an Excel spreadsheet, not a UserForm.
I have the following code, if the Dropdown is opened it requeries Cbo2 to
ListIndex = 0. But I also want it to close (unselect, undrop list) Cbo2 &
open (select, dropdown) Cbo1 on MsgBox error. This insures the user selects
property of Cbo1 first. - Private Sub cbo2_MouseDown(ByVal Button As Integer, _
-
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
-
-
If Cbo1.Value = "0" Then
-
-
MsgBox "Error, choose ComboBox1, first"
-
Cbo2.ListIndex = 0
-
-
'I want to deselect the Cbo2 DropDown
-
Cbo2.DropDown = False 'Compile error here
-
'Select Cbo1, like Select.Range
-
Cbo1.DropDown
-
-
Else
-
Cbo2.ListIndex = 0
-
End If
-
End Sub
--
Thanks, Kevin
16 10574 NeoPa 32,566
Recognized Expert Moderator MVP
There seems to be no way to cancel the .Dropdown explicitly Kevin (not that I could find anyway) however, setting the focus to another control (and then back again if required) seems to do the trick for you.
Good luck & Welcome to Bytes!
It won't work in the MouseDown event, but in the MouseUp you can use SendKeys and send F4. Warning, the F4 will do a dropdown if it is not already dropped down, and I know of no way of determining the state of the dropdown list. FishVal 2,653
Recognized Expert Specialist
The following seems to be an undocumented feature - that means you've been warned.
Any operation with MSForms.Combobo x.Locked property makes dropdown list dissapear.
e.g.
the following code does nothing, but calling "Lock" property which results in dropdown list disappearing. -
dummy = <combobox ref>.Locked
-
FYI: DropDown is a method of MSForms.Combobo x class. You cannot assign value to it (like you could do with property) and the only thing it does is showing dropdown list.
Regards,
Fish
PS. "Locked" property seems to be not the only option - actually, one from a bunch.
A trivial -
With <combobox ref>
-
.Value = .Value
-
End With
-
does the same.
NeoPa 32,566
Recognized Expert Moderator MVP @FishVal
I tried that one Fish (some experimenting to see if I could find something), and it didn't work for me. I use Access 2003.
FishVal 2,653
Recognized Expert Specialist
Instead of the MouseDown sub, I tried a Change sub with a Cbo.Enable = True/False to disable and enable the proceeding Active ComboBoxes. It works great for the Cascading Dropdowns.
However I’m getting a “Run-time error 1004” on the Enable = True/False, from my CmdButton sub “CmdRefreshAll_ Click” (see 2nd sub below). It has an ActiveWorkbook. RefreshAll. I even tried reversing the If in the Cbo. - Private Sub Cbo1_Change()
-
If Cbo1.Value = "0" Then
-
Cbo2.ListIndex = 0
-
Cbo3.ListIndex = 0
-
Cbo4.ListIndex = 0
-
'Run-time error 1004 on ActiveWorkbook.RefreshAll (see CmdRefreshAll sub)
-
Cbo2.Enabled = False
-
Cbo3.Enabled = False
-
Cbo4.Enabled = False
-
Else
-
Cbo2.ListIndex = 0
-
'Run-time error 1004 on ActiveWorkbook.RefreshAll (see CmdRefreshAll sub)
-
Cbo2.Enabled = True
-
End If
-
End Sub
-
-
Private Sub CmdRefreshAll_Click()
-
'Refresh data sheets from outside data sources & Pivotsheets
-
Application.ScreenUpdating = False
-
ActiveWorkbook.RefreshAll
-
'Add RefreshAll date & time to Form page
-
Sheets(1).Select
-
Range("H1").Value = "Refresh All Date: "
-
Range("H2").Value = Now
-
Application.ScreenUpdating = True
-
MsgBox "All Data Sheets & Pivot Tables in this Workbook are updated"
-
End Sub
NeoPa 32,566
Recognized Expert Moderator MVP @FishVal
Ah. I missed that.
NeoPa 32,566
Recognized Expert Moderator MVP
Kevin,
I have edited two of your posts now that included code without the tags. I left edit comments but it appears you haven't noticed them. Please use the tags in future.
Administrator.
PS. Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your Profile Options (Look near the bottom of the page).
Is it possible to disable sheet1 from being Refreshed by an ActiveWorkbook. RefreshAll?
It would resolve the Run-time error in the cbo.Click sub for sheet1. I don't want it to distrub the CboBoxes anyway.
I only want the ActiveWorkbook. RefreshAll to Refresh the data/Pivot sheets.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Albretch |
last post by:
Hi,
client wants for a window with no toolbars to open (technical and
'esthetical' reasons) after the window, user clicks on, is being
closed.
I told them about security settings in browsers and no cross-browsers
solutions and all of that we know, but they have told me they have
seen that before and how then the annoying pop-up windows...
|
by: alan_sec |
last post by:
I' m sending query to DB2 7.2 (installed on Win 2000) using JDBC driver
COM.ibm.db2.jdbc.net.DB2Driver like this:
String query = "SELECT dercert from vacert "
+ "WHERE vrijediod=(select max(vrijediod) from vacert where
vrijediod<?)";
java.sql.Timestamp timeStamp = new
java.sql.Timestamp(System.currentTimeMillis());
|
by: Chris Becker |
last post by:
This is my attempt to rephrase a question I asked earlier that got no
response. I suspect it was my poor/unplanned wording. Here is another
attempt:
I have a form with some drop down lists. I would like the user to be able
to start filling in the form, then get to one of the dropdown lists (ex:
Service Type) and realize that the dropdown...
|
by: Lauchlan M |
last post by:
I get the following error. Apart from the fact that it does not make any
grammatical sense, what would be likely to be causing it?
The background is that nxCmdDeleteErrorLogItem is a delete command with the
SQL
Delete from ErrorLog where LogID = ?
and LogID is a parameter corresponding to a DB field LogID which is an
autoinc field...
|
by: Lauchlan M |
last post by:
I get the following error. Apart from the fact that it does not make any
grammatical sense, what would be likely to be causing it?
I have a command component 'nxCmdDeleteErrorLogItem' with the following SQL:
Delete from ErrorLog where LogID = ?
LogID is a parameter corresponding to a DB field LogID which is an autoinc
field (the...
| |
by: Karan |
last post by:
I am calling finalize when form2 loads and deactivates form1 which closes
form1. However, same thing is not happening in form2 because finalize is
already called. Does anybody has solution to it. This code works well for
splash screen. I searched alot on net for codes but they don't work. for
example-
(1)
Public Sub CloseForm(formType As...
|
by: Toccoa |
last post by:
After considerable googling - I mean searching with Google(r) - I
could not find javascript on a button or <a href=... to close a
window in the latest versions of IE and FireFox.
There seemed to be two techniques for earlier versions. But the
window.opener='' ;window.close();
and the
window.open('','_parent','') ;window.close();
...
|
by: William Youngman |
last post by:
I have a gridview displaying data and would like to use the AJAX dropdown extender so that when the user clicks on a record a dropdown menu will display providing the user with a menu of selections to choose from (yes much like the SharePoint 2007 dropdown menu).
I'm having problems dynamically binding the 'TargetControlID' property of the...
|
by: ncsthbell |
last post by:
I have an Access 2000 database (running on Windows XP) that is used as a model and each user grabs a copy of this and puts onto their own drive. I have had 2 folks have issues with it lately. When they try to open it, the application does not fully open. What you see is a blank grey form with the dark blue title bar at the top with the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |