473,385 Members | 1,875 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,385 software developers and data experts.

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.Name).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 2202
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_NotInList(NewData As String, Response As Integer)
Dim intResponse As Integer, strComboName As String
'Remove the _NotInList to get the combo name
strComboName = Me.ActiveControl.Name
MyNotInList(NewData, intResponse, strComboName)
Response = intResponse
End Sub

Public Sub MyNotInList(NewData 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 = acDataErrContinue)
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*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.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.Name).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 programmatically - 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
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?...
5
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...
1
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. ...
4
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...
11
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...
3
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...
7
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...
1
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...
6
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,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.