473,671 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Not in list" event for Access 2007

46 New Member
I cannot get the not in list event to work right.

On my form I have a combo box named "cboChargeC ode"

I have a table named "tblChargeC ode"

I would like it so when you enter a value into the cbohargeCOde that is not listed it will alert you and ask you if you would like to add such item.

My code
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub ChargeCode_NotInList(NewData As String, Response As Integer)
  3. Dim strSQL As String
  4. Dim i As interger
  5. Dim MSg As String
  6.  
  7. 'Exit this sub if the combo box is cleared
  8. If NewData = "" Then Exit Sub
  9.  
  10. MSg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
  11. MSg = MSg & "Do you want to add it?"
  12.  
  13. i = MSgBox(MSg, vbQuestion + vbYesNo, "Unknown Charge Code...")
  14. If i = vbYes Then
  15.     strsql = "Insert into tblChargeCode ([strChargeCode])" & CurrentDb.excute strSQL, dbFailOnError
  16.     Response = acDataErrAdded
  17. Else
  18.     Response = acDataErrContinue
  19. End If
  20.  
error occurs on line:
Expand|Select|Wrap|Line Numbers
  1. strsql = "Insert into tblChargeCode ([strChargeCode])" & CurrentDb.excute strSQL, dbFailOnError
  2.  
I got this code form Microsoft so...
not sure what is going on or why it doesnt work, any help would be awesome!
Thanks
Apr 1 '09 #1
6 6736
RuralGuy
375 Recognized Expert Contributor
Recheck where you got the code from (Microsoft). You'll see it is not the same.
Apr 1 '09 #2
vanlanjl
46 New Member
I figured it out.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3.  
  4. Private Sub cboChargeCode_NotInList(NewData As String, Response As Integer)
  5. Dim strSQL As String
  6. Dim i As Integer
  7. Dim MSg As String
  8.  
  9. 'Exit this sub if the combo box is cleared
  10. If NewData = "" Then Exit Sub
  11.  
  12. MSg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
  13. MSg = MSg & "Do you want to add it?"
  14.  
  15. i = MsgBox(MSg, vbQuestion + vbYesNo, "Unknown Charge Code...")
  16. If i = vbYes Then
  17.     strSQL = "Insert into tblChargeCode ([ChargeCode])" & " VALUES ('" & NewData & "')"
  18.     CurrentDb.Execute strSQL, dbFail
  19.     Response = acDataErrAdded
  20. Else
  21.     Response = acDataErrContinue
  22. End If
  23. End Sub
  24.  
Apr 1 '09 #3
RuralGuy
375 Recognized Expert Contributor
Excellent! Glad you got it sorted.
Apr 1 '09 #4
92Felton
1 New Member
Hey I'm Felton and here for the first time. I came across this thread and I find It truly useful & it helped me out much. I hope to give something back and aid others like you aided me.
Dec 8 '11 #5
RuralGuy
375 Recognized Expert Contributor
Welcome. Glad we could help.
Dec 8 '11 #6
NeoPa
32,569 Recognized Expert Moderator MVP
Suspicion alert:
Why would this help anyone but the OP? It's not like it's a common mistake to make, and it's all about the OP's mistake.

If 92Felton goes on to post normally then no problem. If, on the other hand, they post anything suspicious, then this should not be taken to indicate their motives are pure.
Dec 9 '11 #7

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

Similar topics

1
5457
by: Kamal | last post by:
I am trying to send mail through smtp. smtp service is running on my machine. But every time during the smtpmail.send(msg) call gives "Could not access 'CDO.Message' object." error. Could some one help me out to resolve this issue. Thanks in advance, Kamal
1
2695
by: Jens Øster | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send e-mail addresses out side my company walls. When the e-mail is send on some one in my company it works perfect. I think it is a relay issue. Our system administrator will not allow relaying. In the ASP.Net web.config file I let the web application...
3
9252
by: Jens | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send e-mail addresses out side my company walls. When the e-mail is send on some one in my company it works perfect. I think it is a relay issue. Our system administrator will not allow relaying. In the ASP.Net web.config file I let the web application...
4
3967
by: Liz Patton | last post by:
Here's the exception: System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80004005): Unspecified error --- End of inner exception stack trace ---
2
2400
by: chuckdfoster | last post by:
I am getting a "Could Not Access CDO.Message Object" Error when I try to use the following code to send an email via ASP.NET. When I run this on one machine it works, on another one it doesn't. Both have VS.NET installed and both have MS Outlook installed. What do I need done to the machine that doesn't work? Or is something wrong with the code? Dim email as New System.Web.Mail.Message email.To = "me@me.com" email.Subject = "Test...
5
15122
by: lds | last post by:
I am getting the following error: The "SendUsing" configuration value is invalid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.
1
2444
by: Jason | last post by:
I am trying to send mail via SMTP, using VB.NET on XP. I keep getting this error: "Could not access 'CDO.Message' object." (I can send mail fine via VB6, using CDONTS.) I have added a reference to System.Web, and this is my code: Try WebMailMessage.From = Sender
2
8429
by: Rico | last post by:
Hello, Is there any way to get rid of or replacing the error message that pops up when you enter a combo box item that isn't in the list? I've tried using the Not In List event, but there is still an Access error that is raised. Any ideas? Thanks! Rick
3
9555
by: PW | last post by:
Hi, One of our clients is getting that error when they are trying to save a record but I can not duplicate it here. The data is on another PC and is linked to two workstations. The code (listed below) is just saving interests selected from a multi-list list box. I've never seen that error message before. Any ideas? What does it
0
8402
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
8927
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
8825
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
8605
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,...
0
8676
tracyyun
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...
0
7445
agi2029
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 projectplanning, coding, testing, and deploymentwithout 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...
1
6237
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
5703
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();...
2
1816
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.