Hello all,
I am creating an application that has an equipment inventory and maintenance form that has numerous subforms that are displayed depending on the category of equipment selected.
I have two common combo boxes on each subform - "Supplier" and "Manufactur er". I use the following code for the "NotInList" event and it works fine. (This is the version for the "Supplier" cbo)
[i] -
[i]Public Sub cboSupplier_NotInList(NewData As String, Response As Integer)
-
On Error GoTo cboSupplier_NotInList_Err
-
Dim intAnswer As Integer
-
Dim strSQL As String
-
-
intAnswer = MsgBox("The Supplier " & Chr(34) & NewData & _
-
Chr(34) & " is not currently listed." & vbCrLf & _
-
"Would you like to add it to the list now?" _
-
, vbQuestion + vbYesNo, "I-TEAM Utilities")
-
If intAnswer = vbYes Then
-
strSQL = "INSERT INTO tbl_Suppliers([SupName]) " & _
-
"VALUES ('" & NewData & "');"
-
DoCmd.SetWarnings False
-
DoCmd.RunSQL strSQL
-
DoCmd.SetWarnings True
-
MsgBox "The new Supplier has been added to the list." & _
-
" Please enter remaining contact information" & vbCrLf & _
-
"before proceeding further" _
-
, vbInformation, "I-TEAM Utilities"
-
Response = acDataErrAdded
-
DoCmd.OpenForm "frm_Test2"
-
Else
-
MsgBox "Please choose a Supplier from the list." _
-
, vbInformation, "I-TEAM Utilities"
-
Response = acDataErrContinue
-
End If
-
cboSupplier_NotInList_Exit:
-
Exit Sub
-
cboSupplier_NotInList_Err:
-
MsgBox Err.Description, vbCritical, "Error"
-
Resume cboSupplier_NotInList_Exit
-
-
End Sub
I would like to include these once as a public function or sub and call them with the NotInList event of each combo box but have had no success in getting this to work. The row source tables are the same for these cbo boxes on all 18 subforms.
2 2629
I have never tried this, but you should be able to get it to work if you add the form object to the sub's arguments as shown. Also, give the sub a slightly different name (g = global) to distinguish from the form's not in list event, which will fire if the limit to list property is set to yes and the item entered is not on the list. Essentially all you are doing is passing the NotInList call from the local to central processing. -
Public Sub gcboSupplier_NotInList(Frm As Form, NewData As String, Response As Integer)
When the NotInList event is fired for the form, just call the public sub and pass the required parameters. -
Private Sub cboSupplier_NotInList()
-
gcboSupplier_NotInList(Me)
-
-
End Sub
You Sir are a prince among PuppyDogBuddies .
Works like a charm.
Thanks a million
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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
|
by: whilstiwait |
last post by:
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
|
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.
|
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...
| |
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), & ...
|
by: Stinky Pete |
last post by:
Hi (again) ;-)
I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.
I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.
|
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...
|
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
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |