473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MS Access VB error 424

i am trying to get the NotInList function working properly in MSAccess. my scenario is that i am trying to get it to add names to a combo list box if they aren't already in there. i gets to the point where the popup asks me if i want to add the user to the list. i click yes and i get "424 - object required". i have been looking on the internet for a few days now on how to resolve it, but no luck. hopefully someone here can help me. thanks in advance. [code below]

*PRININVEST is the name of the combolist box
*the rest of the code was copied from someone else, so it might just be something not matching, but then again the Object required is coming up...


Private Sub PRININVEST_NotInList(NewData As String, Response As Integer)
Const cProcedureName As String = "PRININVEST_NotInList"
On Error GoTo err_handler
Dim db As DAO.Database
Dim rst As ADODB.Recordset

If MsgBox("This name doesn't exist. Add?", vbYesNo + vbQuestion) = vbYes Then
Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset(proposal.PRININVEST)
rst.AddNew
rst!StateDesc = NewData
rst.Update
Response = acDataErrAdded
Else
Me.Undo
Response = acDataErrContinue
End If

Exit_Sub:
On Error Resume Next
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
err_handler:
Select Case Err
Case Else
'Call LogError(err.Number, err.Description, cModuleName & cProcedureName)
MsgBox Err.Number & " - " & Err.Description
End Select
Resume Exit_Sub
End Sub
Jun 14 '06 #1
1 7193
PEB
1,418 Expert 1GB
i am trying to get the NotInList function working properly in MSAccess. my scenario is that i am trying to get it to add names to a combo list box if they aren't already in there. i gets to the point where the popup asks me if i want to add the user to the list. i click yes and i get "424 - object required". i have been looking on the internet for a few days now on how to resolve it, but no luck. hopefully someone here can help me. thanks in advance. [code below]

*PRININVEST is the name of the combolist box
*the rest of the code was copied from someone else, so it might just be something not matching, but then again the Object required is coming up...


Private Sub PRININVEST_NotInList(NewData As String, Response As Integer)
Const cProcedureName As String = "PRININVEST_NotInList"
On Error GoTo err_handler
Dim db As DAO.Database
Dim rst As ADODB.Recordset

If MsgBox("This name doesn't exist. Add?", vbYesNo + vbQuestion) = vbYes Then
Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset(proposal.PRININVEST)
rst.AddNew
rst!StateDesc = NewData
rst.Update
Response = acDataErrAdded
Else
Me.Undo
Response = acDataErrContinue
End If

Exit_Sub:
On Error Resume Next
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
err_handler:
Select Case Err
Case Else
'Call LogError(err.Number, err.Description, cModuleName & cProcedureName)
MsgBox Err.Number & " - " & Err.Description
End Select
Resume Exit_Sub
End Sub
Hi,

try:
Expand|Select|Wrap|Line Numbers
  1. Private Sub PRININVEST_NotInList(NewData As String, Response As Integer)
  2. Const cProcedureName As String = "PRININVEST_NotInList"
  3. On Error GoTo err_handler
  4. Dim db As Database
  5. Dim rst As Recordset
  6.  
  7.   If MsgBox("This name doesn't exist. Add?", vbYesNo + vbQuestion) = vbYes Then
  8.     Set db = Currentdb()
  9.     Set rst = db.OpenRecordset("proposal.PRININVEST")
  10.     rst.AddNew
  11.       rst("StateDesc") = NewData
  12.     rst.Update
  13.     Response = acDataErrAdded
  14.   Else
  15.     Me.Undo
  16.     Response = acDataErrContinue
  17.   End If
  18.  
  19. Exit_Sub:
  20.   On Error Resume Next
  21.   rst.Close
  22.   Set rst = Nothing
  23.   Set db = Nothing
  24.   Exit Sub
  25. err_handler:
  26.   Select Case Err
  27.   Case Else
  28.     'Call LogError(err.Number, err.Description, cModuleName & cProcedureName)
  29.     MsgBox Err.Number & " - " & Err.Description
  30.   End Select
  31.   Resume Exit_Sub
  32. End Sub
  33.  
Hope that proposal.PRININVEST is the name of a table!

:)
Sep 23 '06 #2

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

Similar topics

3
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
1
by: annie | last post by:
Hi all, I have recently ported my Access 2000 app to SQL Server, keeping the Access client as the front end using linked tables. I am also using triggers on my SQL tables to trap orphan...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
9
by: Fish Womper | last post by:
I am at best a part time developer of Access databases. I use Access 2.0, as this is all my employer has on its computers. Even so, to use this ancient version requires a fairly convoluted...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
0
by: Sebastian | last post by:
Hello I develop my applications in Access 2002. My development system is running Windows XP SP2 and I have Microsoft Office XP Developer. Microsoft Office XP is at SP3. I used Inno Setup (great...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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 project—planning, coding, testing,...

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.