473,657 Members | 2,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help....Getting double entries using recordset (AfterUpdate)

imrosie
222 New Member
Please help with this one,,,,,I've been trying everything in my arsenal to fix this one. I'm stumped....

I"ve got a unbound combo box (customername) that has two events (on click); AfterUpdate and NotInList.

The AfterUpdate uses a 'me.recordsetcl one' in order to display other data in controls associated with customerid/customername from the Customer table.

The NotInlist, does just that, adds a new customer name to the
list along with a new autonumber (used as customerid).

The problem is that I'm getting two entries (different autonumbers). I can't figure out what I'm doing wrong. If I remove the 'AfterUpdate' event, then I can't bring up the customer's data, since then there's no connection to the customername/customerid.

If I remove the Not in List, then there's no way to add a new customer. I reconfigured NotInList many many times and still I get 2 entries. One entry has Customer 'name only', The second entry has name, address, city and the rest of the fields as entered.

I tried setting an index (on Customer table) with CustID and CustomerID, making them unique, but still I'm getting 2 entries whenever I use the 'NotInList'.... ......Help Help,,

Here are these events:
Expand|Select|Wrap|Line Numbers
  1. Private Sub customername_AfterUpdate()
  2. Dim rst As Object
  3.  
  4. Set rst = Me.RecordsetClone
  5.  
  6. rst.FindFirst "CustomerID=" & Me![customername]
  7. If Not rst.NoMatch Then
  8.  
  9.   Me.Bookmark = rst.Bookmark
  10. Else
  11.   'Not found!
  12. End If
  13. Forms![Add or Delete Customer]![customername].Requery
  14. End Sub
  15.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub customername_NotInList(NewData As String, Response As Integer)
  2. Dim strSQL
  3. Dim FirstName As String
  4. Dim LastName As String
  5. Dim SpacePosition As Integer
  6. Dim lngNextID As Long
  7.  
  8.     ' Find the highest Cust ID in the Customers table and add 1
  9.     lngNextID = DMax("[CustID]", "Customers") + 1
  10.     custID = lngNextID
  11.  
  12.    SpacePosition = InStr(NewData, " ")
  13.     If SpacePosition = 0 Then
  14.         MsgBox "Your entry requires a space to separate First and Last name." & _
  15.                vbNewLine & vbNewLine & _
  16.                "Please enter a First and Last Name or choose an entry from the list.", _
  17.                vbInformation, "Invalid Data !"
  18.         Response = acDataErrContinue
  19.         Exit Sub
  20.     End If
  21.  
  22.     ' Trim the data into first and last name using the space position.
  23.     FirstName = Trim(Left(NewData, SpacePosition - 1))
  24.     LastName = Trim(Mid(NewData, SpacePosition + 1))
  25.  
  26.     If FirstName = "" Then
  27.         MsgBox "You have not entered details for the first name" & vbNewLine & vbNewLine & _
  28.                "Please fix entry.", vbInformation, "Invalid Data !"
  29.         Response = acDataErrContinue
  30.         Exit Sub
  31.     End If
  32.  
  33.     If LastName = "" Then
  34.         MsgBox "You have not entered details for the last name" & vbNewLine & vbNewLine & _
  35.                "Please fix entry.", vbInformation, "Invalid Data !"
  36.         Response = acDataErrContinue
  37.         Exit Sub
  38.     End If
  39.  
  40.     MsgBox "An account for this person does not exist....." & vbNewLine & vbNewLine & _
  41.            "Now creating new Customer Account.", vbInformation, "Unknown Customer Details....."
  42.     strSQL = "Insert Into Customers ([custID], [FirstName], [LastName]) " & _
  43.     "values ('" & custID & "','" & FirstName & "','" & LastName & "');"
  44.     'MsgBox strsql
  45.     CurrentDb.Execute strSQL, dbFailOnError
  46.     Response = acDataErrAdded
  47.  
  48. End Sub
  49.  
CustID is NOT an autonumber. I've also done the After Update with and without the '.Requery', it doesn't make a difference.
Does anyone know how to fix this? thanks so much....
Rosie
Jul 30 '07 #1
1 1871
NeoPa
32,568 Recognized Expert Moderator MVP
Have you managed to get anywhere with this yet Rosie?
Aug 3 '07 #2

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

Similar topics

4
4748
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record onto the bottom of the list (even though it keeps its record number). Also, There are certin names that i click on the list, and it will not bring it up, rather it brings to the first record (no matter how many times i try going to that...
5
1379
by: Koen | last post by:
Hi all, I created a function that updates a certain status field. The status can be influenced by four different other fields. So, on the form where I edit these fields I call the function (see below) from the AfterUpdate events of each of the four fields. The problem is, that the query in the function uses the _old_ value of the updated field! I want it to use the _updated_ value and thought the _AfterUpdate_ event would do the trick.
3
1341
by: Jim | last post by:
I am just starting to put together a simple First name, Last name, Address, City/State, Zip, Phone, & etc. database and I have several thousand entries to make, many of which will have the same City/State and Zip code. I am running Access 2000 v 9.0 Is there not an "auto complete" function that will assist in the repetitive entry of all these same field entries?
9
2408
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a single string separated by a user defined character. There is no error trapping (by design), USE AT YOUR OWN RISK.
11
2794
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...
4
1395
by: David | last post by:
Hi, Please can you help me get this code to run ? -------------------- Dim dbs2 As DAO.Database, rst2 As DAO.Recordset, str2 As String Set dbs2 = CurrentDb strtest2 = "SELECT products.ProdCode, products.ProductIdentify FROM
5
2186
by: noLoveLusT | last post by:
hi everyone i am very very new to the sql server (2 days actually and ) so far i learned creating SPs etc but couldnt workout how to get return value from my prodecure my sp as follows ________________________ CREATE PROCEDURE . @PageIndex INT, @PageSize INT, @Total INT OUTPUT
47
2858
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could help. I work in a library and send out dual language books to babies of dual or other nationality. The db is to be used for logging a range of book titles and numbers ordered and books sent out to individuals. I am trying to work out a way of...
2
1955
imrosie
by: imrosie | last post by:
Hello, I have a search form that uses a row query to locate a customer by customerID and first & last names, so it's an unbound control. I also have two events associated with this control, 'NotInList' (for customer not in table) and AfterUpdate event which (uses RecordsetClone by customeriD. The Recordsetclone event allows for the other data stored associated with the customer that's located. However, a strange thing occurs when a new...
0
8305
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,...
0
8823
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
8726
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
8503
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,...
1
6163
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
5632
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();...
0
4151
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...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1604
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.