Hi...I have a number of Combo Boxes on a form. If one types a name
which is not in the table, I want it to add the typed, new item. I am
using the following code to do this and it works well, except for one
thing - each new item is added as a new record. I want the new name to
be added after the last entry in the relevant field...is this possible
- preferably by tweaking the code I am using already?
Private Sub Supermarket_Not InList(NewData As String, Response As
Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContin ue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordse t("Businesses ", dbOpenDynaset)
Rs.AddNew
Rs![Supermarket] = NewData
Rs.Update
Response = acDataErrAdded
End If
End Sub
Thanks...Rob 10 1917
If you have an autonumber in your table, sort "Businesses " on the autonumber
field ascending or descending depending on how you want to see the list. Add
the following line to your code after Response = acDataErrAdded:
Me!NameOfCombob ox.Requery
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help re******@pcdata sheet.com
<ro******@gmail .com> wrote in message
news:11******** **************@ j73g2000cwa.goo glegroups.com.. . Hi...I have a number of Combo Boxes on a form. If one types a name which is not in the table, I want it to add the typed, new item. I am using the following code to do this and it works well, except for one thing - each new item is added as a new record. I want the new name to be added after the last entry in the relevant field...is this possible - preferably by tweaking the code I am using already?
Private Sub Supermarket_Not InList(NewData As String, Response As Integer) Dim Db As DAO.Database Dim Rs As DAO.Recordset Dim Msg As String Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr Msg = Msg & "Do you want to add it?" If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then Response = acDataErrContin ue MsgBox "Try again." Else Set Db = CurrentDb Set Rs = Db.OpenRecordse t("Businesses ", dbOpenDynaset) Rs.AddNew Rs![Supermarket] = NewData Rs.Update Response = acDataErrAdded End If End Sub
Thanks...Rob
"PC Datasheet" <No****@Spam.Co m> schreef in bericht news:me******** ********@newsre ad3.news.pas.ea rthlink.net...
--
-- PC Datasheet Your Resource For Help With Access, Excel And Word Applications 'Resource ???? Over 1175 users have come to me from the newsgroups requesting help '1175 users ???? re******@pcdata sheet.com
--
To Steve:
No-one wants your advertising/job hunting here!
Over 875 !! users from the newsgroups have visited the website to read what kind of a 'resource' you are... (rapidly increasing..)
To the original poster:
Most people here have a common belief that the newsgroups are for *free exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell his services.
And he is known here as a shameless liar with no ethics at all.
Before you intend to do business with him look at: http://home.tiscali.nl/arracom/whoissteve.html
Arno R
Whats worse than his advertising is his sending emails to the person who
asks the question trying to get them to pay him to help them.
Really makes you not want to even write to the group anymore.
I've gotten my share of emails from him offering his help for a fee.
"StopThisAdvert ising" <StopThisAdvert ising@DataShit> wrote in message
news:44******** **************@ text.nova.plane t.nl...
"PC Datasheet" <No****@Spam.Co m> schreef in bericht
news:me******** ********@newsre ad3.news.pas.ea rthlink.net...
--
-- PC Datasheet Your Resource For Help With Access, Excel And Word Applications
'Resource ???? Over 1175 users have come to me from the newsgroups requesting help
'1175 users ???? re******@pcdata sheet.com
--
To Steve:
No-one wants your advertising/job hunting here!
Over 875 !! users from the newsgroups have visited the website to read what
kind of a 'resource' you are... (rapidly increasing..)
To the original poster:
Most people here have a common belief that the newsgroups are for *free
exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell
his services.
And he is known here as a shameless liar with no ethics at all.
Before you intend to do business with him look at: http://home.tiscali.nl/arracom/whoissteve.html
Arno R
"Doc Holiday" <te**********@y ahoo.com> schreef in bericht news:5V******** *********@torna do.texas.rr.com ... Whats worse than his advertising is his sending emails to the person who asks the question trying to get them to pay him to help them. Really makes you not want to even write to the group anymore. I've gotten my share of emails from him offering his help for a fee.
Hmmm,
I am beginning to think that Steve spammed 1175 people ... ???
Could you show me (email me) these unwanted emails please?
I will be glad to expand the info on this topic on the website if you don't mind.
I might even might make a new page.
Arno R
Sent you what i hadnt deleted.
"Arno R" <ar***********@ tiscali.nl> wrote in message
news:44******** **************@ text.nova.plane t.nl...
"Doc Holiday" <te**********@y ahoo.com> schreef in bericht
news:5V******** *********@torna do.texas.rr.com ... Whats worse than his advertising is his sending emails to the person who asks the question trying to get them to pay him to help them.
Really makes you not want to even write to the group anymore. I've gotten my share of emails from him offering his help for a fee.
Hmmm,
I am beginning to think that Steve spammed 1175 people ... ???
Could you show me (email me) these unwanted emails please?
I will be glad to expand the info on this topic on the website if you don't
mind.
I might even might make a new page.
Arno R ro******@gmail. com wrote in
news:11******** **************@ j73g2000cwa.goo glegroups.com: Hi...I have a number of Combo Boxes on a form. If one types a name which is not in the table, I want it to add the typed, new item. I am using the following code to do this and it works well, except for one thing - each new item is added as a new record. I want the new name to be added after the last entry in the relevant field...is this possible - preferably by tweaking the code I am using already?
Private Sub Supermarket_Not InList(NewData As String, Response As Integer) Dim Db As DAO.Database Dim Rs As DAO.Recordset Dim Msg As String Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr Msg = Msg & "Do you want to add it?" If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then Response = acDataErrContin ue MsgBox "Try again." Else Set Db = CurrentDb Set Rs = Db.OpenRecordse t("Businesses ", dbOpenDynaset) Rs.AddNew Rs![Supermarket] = NewData Rs.Update Response = acDataErrAdded End If End Sub
Thanks...Rob
The code between the Else and End If is what is the problem. I'd
need to know the recordsource of your combobox before being sure,
but I think you want to change the code to
Else
me.[supermarket] = newdata
Response = acDataErrAdded
End IF
Post the recordsource for the combobox. If it's a named query, post
that as well.
--
Bob Quintal
PA is y I've altered my email address.
"PC Datasheet" <No****@Spam.Co m> wrote in
news:me******** ********@newsre ad3.news.pas.ea rthlink.net: If you have an autonumber in your table, sort "Businesses " on the autonumber field ascending or descending depending on how you want to see the list. Add the following line to your code after Response = acDataErrAdded: Me!NameOfCombob ox.Requery
Bzzzzt! Wrong Answer.
--
Bob Quintal
PA is y I've altered my email address.
Thanks. Had no intentions of going any further with Steve - idiot. Why
would anyone pay someone when there are more competent experts on the
newsgroups who are willing to help for nothing?
Bob - do you mean the Row Source? If so, it is:
SELECT [Businesses].[Supermarket] FROM Businesses;
If I use your code above, I get the error message that "The text you
entered isn't an item in the list. Select an item from the list....
"PC Datasheet" <No****@Spam.Co m> wrote in message
news:me******** ********@newsre ad3.news.pas.ea rthlink.net... If you have an autonumber in your table, sort "Businesses " on the autonumber field ascending or descending depending on how you want to see the list. Add the following line to your code after Response = acDataErrAdded: Me!NameOfCombob ox.Requery
Hahahahahaha ... oww, my sides, stop it ... ahhhh hahahaha! And I thought
Frasier was funny ... This thread has been closed and replies have been disabled. Please start a new discussion. 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: mal |
last post by:
Have tried numerous ideas from the group to solve this one. It is such
a simple example that it should be straightforward ! I just want to
add a new item to a combo that has data from a file, by typing in the
new value , adding to the file and the requerying to get the new valus
in the list. i.e. a data entry and data display combo box.
I select an item from cmb1 and cmb2. I focus on cmb3 and the user can
type a new value. This then adds...
|
by: mal |
last post by:
Sorry for repost - system added to another subject for some reason
Have tried numerous ideas from the group to solve this one. It is such
a simple example that it should be straightforward ! I just want to
add a new item to a combo that has data from a file, by typing in the
new value , adding to the file and the requerying to get the new valus
in the list. i.e. a data entry and data display combo box.
I select an item from cmb1 and...
|
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: 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: imrosie |
last post by:
Hello, I need help. I have a 'NotInlist' routine that appears to givbe me 2 entries of the same new customer. It first adds the name to the list, then when I fill in other customer data (i.e., address, city, phone etc.)...I end up with two separate entries of the same customer (different customer id's (assigned through an autonumber)
I found this out after looking in the Customer table to see that 1st the name goes into the Customer table,...
|
by: EManning |
last post by:
I have a combobox whose rowsource is a union query. This query
displays a person's name in "lastname, firstname" format and in
"firstname lastname" format. The query results look like this:
Mouse, Mickey
Mickey Mouse
When a person is added, the querys' underlying recordset is updated in
the NotInList event. I can't figure out how to refresh the combobox
to display the new person. I get the standard error message that the
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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...
|
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...
|
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: 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();...
|
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: 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...
| |