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: - Private Sub customername_AfterUpdate()
-
Dim rst As Object
-
-
Set rst = Me.RecordsetClone
-
-
rst.FindFirst "CustomerID=" & Me![customername]
-
If Not rst.NoMatch Then
-
-
Me.Bookmark = rst.Bookmark
-
Else
-
'Not found!
-
End If
-
Forms![Add or Delete Customer]![customername].Requery
-
End Sub
-
- Private Sub customername_NotInList(NewData As String, Response As Integer)
-
Dim strSQL
-
Dim FirstName As String
-
Dim LastName As String
-
Dim SpacePosition As Integer
-
Dim lngNextID As Long
-
-
' Find the highest Cust ID in the Customers table and add 1
-
lngNextID = DMax("[CustID]", "Customers") + 1
-
custID = lngNextID
-
-
SpacePosition = InStr(NewData, " ")
-
If SpacePosition = 0 Then
-
MsgBox "Your entry requires a space to separate First and Last name." & _
-
vbNewLine & vbNewLine & _
-
"Please enter a First and Last Name or choose an entry from the list.", _
-
vbInformation, "Invalid Data !"
-
Response = acDataErrContinue
-
Exit Sub
-
End If
-
-
' Trim the data into first and last name using the space position.
-
FirstName = Trim(Left(NewData, SpacePosition - 1))
-
LastName = Trim(Mid(NewData, SpacePosition + 1))
-
-
If FirstName = "" Then
-
MsgBox "You have not entered details for the first name" & vbNewLine & vbNewLine & _
-
"Please fix entry.", vbInformation, "Invalid Data !"
-
Response = acDataErrContinue
-
Exit Sub
-
End If
-
-
If LastName = "" Then
-
MsgBox "You have not entered details for the last name" & vbNewLine & vbNewLine & _
-
"Please fix entry.", vbInformation, "Invalid Data !"
-
Response = acDataErrContinue
-
Exit Sub
-
End If
-
-
MsgBox "An account for this person does not exist....." & vbNewLine & vbNewLine & _
-
"Now creating new Customer Account.", vbInformation, "Unknown Customer Details....."
-
strSQL = "Insert Into Customers ([custID], [FirstName], [LastName]) " & _
-
"values ('" & custID & "','" & FirstName & "','" & LastName & "');"
-
'MsgBox strsql
-
CurrentDb.Execute strSQL, dbFailOnError
-
Response = acDataErrAdded
-
-
End Sub
-
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
1 1871 NeoPa 32,568
Recognized Expert Moderator MVP
Have you managed to get anywhere with this yet Rosie?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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.
|
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?
|
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.
|
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: 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
|
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
|
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...
|
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...
|
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: 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |