473,667 Members | 2,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting .notinlist from VBA

I have a form containing a number of unbound combo boxes in three
columns. Each column has boxes named "aaaa0", "aaaa1", etc. Using
syntax like:

With Forms(Me.Form.N ame).Controls(" txtTechnology" & i)
.AfterUpdate = "=txtTechnology _Change(" & i & ")"
.OnEnter = "=txtTechnology _OnEnter(" & i & ")"
End With

I can set events to a common routine for all the boxes, and in the
events use the passed ID (i) to reference the data in the combo box
that fired the event (using "with...")

I can set a .notinlist event, using syntax like:

.OnNotInList = "=txtTechnology _NotInList(" & i & ",0)"

which I know is not correct, but the event does fire. The ID doesn't
pass in.

The question: what syntax should I use on the .notinlist line to match
up the the (newData, Response) format of the notinlist event?

Thanks,

Keith

Nov 13 '05 #1
2 2217
The problem is, as you note, getting the functionallity of the built-in
parameters. If the NotInList routine is fairly complicated or a lot of
typing, you can do what you are wanting, but you'll need to use the
NotInList event to call the consolidated routine. Set the On NotInList to
[Event Procedure] then in the event procedure, pass the information to your
consolidated routine. You should even be able to pass a value for Response
to the consolidated routine. If you pass it ByRef and change it in the
consolidated routine, you will get the change back in the calling event. You
would then assign this changed value to Response once you return from the
consolidated routine.

Example:
Private Sub cboMyCombo1_Not InList(NewData As String, Response As Integer)
Dim intResponse As Integer, strComboName As String
'Remove the _NotInList to get the combo name
strComboName = Me.ActiveContro l.Name
MyNotInList(New Data, intResponse, strComboName)
Response = intResponse
End Sub

Public Sub MyNotInList(New Data As String, ByRef intResponse As Integer,
strCombo As String)
'Do your add routine here.
'Set the value of intResponse before you exit, just as you would set the
value
'for Response in the normal sub.
'(intResponse = acDataErrAdded or intResponse = acDataErrContin ue)
End Sub

The normal way of passing data in VBA is ByRef, so the ByRef keyword may not
be needed. However, it also shouldn't hurt anything and will serve as a
reminder of what you're trying to do.

--
Wayne Morgan
MS Access MVP
<wh*********@gm ail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
I have a form containing a number of unbound combo boxes in three
columns. Each column has boxes named "aaaa0", "aaaa1", etc. Using
syntax like:

With Forms(Me.Form.N ame).Controls(" txtTechnology" & i)
.AfterUpdate = "=txtTechnology _Change(" & i & ")"
.OnEnter = "=txtTechnology _OnEnter(" & i & ")"
End With

I can set events to a common routine for all the boxes, and in the
events use the passed ID (i) to reference the data in the combo box
that fired the event (using "with...")

I can set a .notinlist event, using syntax like:

.OnNotInList = "=txtTechnology _NotInList(" & i & ",0)"

which I know is not correct, but the event does fire. The ID doesn't
pass in.

The question: what syntax should I use on the .notinlist line to match
up the the (newData, Response) format of the notinlist event?

Thanks,

Keith

Nov 13 '05 #2
Thanks for the suggestion.

Even though it's not correctly formed it does work. I set the ID on the
Enter event and the NotInList picks it up. I was hoping there would be
an easy way to set the event programmaticall y - it's the only one I've
found, so far, that has this problem.

Keith

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2804
by: Pieter Linden | last post by:
Just got done reading some of ADH2000 about comboboxes and the NotInList event... Doesn't look like it's possible to tweak the behavior of this so that I can have a non-text bound column, can I? Say I have a Customers--Invoices relationship, and I want to be able to pick the Customer's name from a combobox. (keeps people from entering the same text - or worse, just almost the same - a zillion times). So I create a CustomerID, enforce...
5
1673
by: David Deacon | last post by:
Hi i have the following code in a CustomerID field if the user enters a notinlist customer then they should dbl click to open the customer form However this error occurs "You tried to assign a null value to a varaible that is not a variant type" My code Dim lngCustomerID As Long If IsNull(Me!) Then
1
1727
by: Steve Leferve | last post by:
Can someone tell what what objects I have to work with on the 'NotInList' event? Basically I want to have a pop-up prompt the user if they want to add the data they typed into the database. Steve Lefevre
4
1805
by: CAD Fiend | last post by:
Hello, I have a combo box (cmbFirstName) on a form that is hitting a query (qryFirstName) and then putting that selected (or typed by user) value to the table field (name FirstName) on the table (tblUserInfo). The query hits a look up table called (lulFirstNames). If the user DOESN'T find the name they want in the combo box, they will just type it in.
11
2795
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
3
1193
by: Bryan | last post by:
I have a listbox that the user is able to add items to through and SQL statement that is run on the NotInList event. At the end of the event, I set Response = acDataErrAdded, telling access that the NewData variable has been added to the underlying table. The recoord gets added to the underlying table just fine. The problem is, after the NotInList event, the afterupdate event is called by access. This is also no problem. But after...
7
6055
by: Bryan | last post by:
I am trying to allow the user to add an item to a list if it is not found in a combobox. When the NotInList event is triggered I run a function "AddItem" that has a custom dialog box to add an item to the underlying table. The function either returns "Not Added", or the new Items ID. I know the function works fine. Whe I try the code below I get errors saying "Close action was cancelled" (referring to my custom popup input box), & ...
1
1883
imrosie
by: imrosie | last post by:
Hello (from Rosie the newbie), I recently got help with a wonderful event to perform this from 'thescripts'...it recognizes that a name is not in the list an allows for (after parsing first and last name) for the addition of the new FullName into the Customer table. I've been working on some other forms in this application and hadn't noticed until now a little problem. The event occurs in a 'search customer' form. You first search an...
6
2676
by: Volker Neurath | last post by:
Hi all, I have a Problem with combobox-property "NotInList" and an unbound Form. The situation: On my main form i have three comboboxes for data-exchange (here: Names of distributor, reseller and final customers, the whole database is made for storing information about quotatations - no, not for quoting itself) ut the boxes actually may not contain all our distributors and reseller's
0
8458
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8888
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8565
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
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 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1779
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.