473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

What combobox events are triggered when an assignment is made to it via vba

I have a combobox (cboTwo) where you type in an office name, and if that office name is not in the list, the NotInList event opens a form. I have another combobox (cboOne) and create a record associating the entries in both comboboxes (many-to-many).

A user wants cboTwo to act like a normal combobox (one-to-many). The problem will be that existing records could legitimately end up being duplicated. Actually, not written, since I've prevented that.

I want to leave the system unchanged and just add a combobox (cboThree) that displays the already associated with the entity selected in cboOne. This works fine. I use the NotInList event on cboThree to assign the value in cboThree to cboTwo. The value does appear in cboTwo, but manually clicking there does nothing.

NotInList appears to process NewData (built in variable that apparently holds the value of the text box component of the combobox while assignment is made to the whole combobox.

The problem is that the NotInList event on cboTwo does not work when I make the assignment. I have put messages boxes in the combobox events, but can't seem to find anything that changes when the assignment was made. I've tried to click cboThree, but again, nothing seems to work.

Any help will be appreciated. Thanks.

Dave44000
Oct 15 '13 #1

✓ answered by zmbd

Sorry,
I had to dig out my notes on ACC2003.
I had something along these same lines in a cascading combobox situation (long story), in anycase: the on_change event and not_in_list events are linked. I had thought this had changed in ACC2010.

From the following you can see that the On_Change event is not triggered by a VBA entry; thus, the not_in_list event is never triggered.

You can call the not_in_list event for the control that you are making the entry via VBA from the other control's not_in_list event; however, it may be better in long run to reconsider the design of the form

---
ComboBox.NotInList Event (Access)
Office 2010
The NotInList event occurs for combo boxes whose LimitToList property is set to Yes, after you enter a value that isn't in the list and attempt to move to another control or save the record. The event occurs after all the Change events for the combo box.
(BTW: Please take a look at the code examples here and compare them with what you are doing... some slight differences. (^_^) )
---
---
Change Event [Access 2003 VBA Language Reference]
Office 2003
Notes
Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.
•This event applies only to controls on a form, not controls on a report.
You can not set the control's text property without setting the focus on the control. You can not change the control focus while within a not_in_list event; thus, you can not trip the on_change event until AFTER the not_in_list event finishes.
---

11 2772
zmbd
5,501 Expert Mod 4TB
The basic Order of events:
Order of events for database objects (v2010)

That's a muddle to follow (@-@)
The problem is that the NotInList event on cboTwo does not work when I make the assignment. I have put messages boxes in the combobox events
Check that the properties are set correctly (ie. not in list, enabled, locked, etc...) When I use VBA to plug in values to my CBO, all of the events fire as expected which is why I am asking you to double check the property settings on your controls.
Oct 15 '13 #2
The properties are

Limit To List Yes
Allow Value List Edits Yes
Enabled Yes
Locked No

Allow Values List Edits is Yes, because the form that gets called adds a record and a the list is refreshed.
Oct 15 '13 #3
zmbd
5,501 Expert Mod 4TB
What is the record source for your CBO?
(sorry should have asked for that in my first post)

> and you might want to take a look at "option 4" in the following:Adding values to lookup tables - Allen Browne
Oct 15 '13 #4
row source is
Expand|Select|Wrap|Line Numbers
  1. SELECT [PhysicianOffice].[PhysicianOfficeID]
  2.    , [PhysicianOffice].[PhysicianOfficeName] 
  3.    FROM PhysicianOffice 
  4.    ORDER BY [PhysicianOfficeName]; 
This works perfectly before the third CBO got involved. If an entry wasn't in the list, it opened a form via the NotInList event. Once the value is assigned from the third CBO, and it is still not in the list, the NotInList event does not fire.
Oct 15 '13 #5
I read option 4, and yes, I'm not letting them add items to the list. They have to create a number of records to create the item. The form is a data entry form.

The hair splitting is caused by the difference between typing an entry in, which works, and assigning a value programmatically. The former opens the form. The latter does not, because I cannot get it to do so.
Oct 15 '13 #6
zmbd
5,501 Expert Mod 4TB
That's reasonable.
Please post the code that is entering the value into your combobox - please remember to use the [CODE/] formating (^-^) to place the code tags.
I think that what's happening is that the focus is still on your second control, thus the afterupdata and notinlist events are not triggering, Seeing your code will help.
Oct 15 '13 #7
The source for the entry assigned to the cbo is cboPOShort, it lists those PhysicianOffices already assigned to Physician. The Physician has already been selected.

Row source for cboShort is


Expand|Select|Wrap|Line Numbers
  1. SELECT [POShortListQ].[PhysicianOfficeID], [POShortListQ].[PhysicianOfficeName] FROM POShortListQ ORDER BY [PhysicianOfficeName]; 
  2.  
The query in the SELECT (POShortListQ) is


Expand|Select|Wrap|Line Numbers
  1. SELECT PhysicianOffice.PhysicianOfficeName
  2. FROM PhysicianOffice INNER JOIN (Physician INNER JOIN PhysicianPhysicianOfficeJT ON Physician.PhysicianID = PhysicianPhysicianOfficeJT.PhysicianID) ON PhysicianOffice.PhysicianOfficeID = PhysicianPhysicianOfficeJT.PhysicianOfficeID
  3. WHERE (((Physician.PhysicianID)=[forms]![frmMain]![cboPhysician]))
  4. ORDER BY PhysicianOffice.PhysicianOfficeName;
  5.  

The Not In List event on the assigning cbo is

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboPOShort_NotInList(NewData As String, Response As Integer)
  2. Me.cboPhysicianOffice = NewData
  3. Me.Txt202 = NewData
  4. Me.cboPOShort = Null
  5. End Sub
  6.  
Oct 15 '13 #8
I added SetFocus to the NotInList event. It cleaned up some left over behavior in cboPOShort. It also selects the value in cboPhysicianOffice. But, the relevant events are still not launching.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboPOShort_NotInList(NewData As String, Response As Integer)
  2. Me.cboPhysicianOffice = NewData
  3. Me.Txt202 = NewData
  4. Me.cboPOShort = Null
  5. Me.cboPhysicianOffice.SetFocus
  6. End Sub
Oct 15 '13 #9
zmbd
5,501 Expert Mod 4TB
Sorry,
I had to dig out my notes on ACC2003.
I had something along these same lines in a cascading combobox situation (long story), in anycase: the on_change event and not_in_list events are linked. I had thought this had changed in ACC2010.

From the following you can see that the On_Change event is not triggered by a VBA entry; thus, the not_in_list event is never triggered.

You can call the not_in_list event for the control that you are making the entry via VBA from the other control's not_in_list event; however, it may be better in long run to reconsider the design of the form

---
ComboBox.NotInList Event (Access)
Office 2010
The NotInList event occurs for combo boxes whose LimitToList property is set to Yes, after you enter a value that isn't in the list and attempt to move to another control or save the record. The event occurs after all the Change events for the combo box.
(BTW: Please take a look at the code examples here and compare them with what you are doing... some slight differences. (^_^) )
---
---
Change Event [Access 2003 VBA Language Reference]
Office 2003
Notes
Setting the value of a control by using a macro or Visual Basic doesn't trigger this event for the control. You must type the data directly into the control, or set the control's Text property.
•This event applies only to controls on a form, not controls on a report.
You can not set the control's text property without setting the focus on the control. You can not change the control focus while within a not_in_list event; thus, you can not trip the on_change event until AFTER the not_in_list event finishes.
---
Oct 15 '13 #10
Thanks!

The move focus tip broke the logjam. Moving the focus change to the last line in the sub made a difference. I almost ignored the behavior change after that, but I went back and put it in again.

I've gone with the on Enter event. I'll put the value in the cbo, the user will click the cbo, and all is well. Help text will suffice. The form works as needed.
Oct 15 '13 #11
Thanks for telling me to rethink my solution.

It took me two more days of struggle before I came up with an easier way. Implementing that, I found an even easier way, far easier.
Oct 18 '13 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Petr Prikryl | last post by:
Hi, When solving the problem of passing the unicode directory name through command line into a script (MS Windows environment), I have discovered that I do not understand what encoding should...
0
by: Jim H | last post by:
I'm trying to use an owner draw ListBox by subscribing to the DrawItem event to draw my custom control as an item in the ListBox. This event is triggered when I drag the scroll button but NOT when...
0
by: dan.j.weber | last post by:
I see some programs declaring the names of class variables in "__slots__". I've looked this up and the docs say something about old and new style classes, whatever that means. Can someone give me a...
2
by: tony | last post by:
Hello!! I know what an abstract class is which mean that the one of the derived class must define the abstract methods in the abstract class. So all the abstract methods in the abstarct class...
1
by: Abel Chan | last post by:
Hi there, I was trying to write a simple NT services using .NET 2.0 and fileSystemWatcher control. The goal is to poll documents from a watch directory and ftp them to a remote web site. I...
1
by: tomcarr1 | last post by:
What event is triggered in ASP.Net when you close the browser ? What event is normally used to trigger clean up stuff when going from one form to another or leaving the project?
1
by: yicong | last post by:
What should i do when i want to save a select resultset,but not in a new table,in memory is the best? thanks!
1
by: freeskier | last post by:
What event is triggered when a combobox is assigned a value? For example, what event is triggered for the combobox in this code: Dim intMenu As Integer intMenu = 2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.