473,467 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding New Data to A Combobox List

35 New Member
This is is a follow up from an old thread for inserting NEW data in to a Combobox which is nice feature, especially for an application for Mobile PC where
data is entered from the field using a handheld device like a PDA.

PLease see thread here
http://www.thescripts.com/forum/thread190072.html
I have now this code in NotInList property of my COmbo box, but it produces an error message
"An error occurred. Please try again." when you enter new data

++++++++++++++
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo84_AfterUpdate()
  2.     ' Find the record that matches the control.
  3.     Dim rs As Object
  4.  
  5.     Set rs = Me.Recordset.Clone
  6.     rs.FindFirst "[RecordNum] = " & Str(Nz(Me![Combo84], 0))
  7.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8. End Sub
  9.  
  10. Private Sub Combo84_NotInList(NewData As String, Response As Integer)
  11. Dim Db As Database, rs As Recordset
  12. Dim strmsg As String
  13. strmsg = "'" & NewData & "' is not in Current List"
  14. strmsg = strmsg & "@You Must Add it to Continue"
  15. strmsg = strmsg & "@Click Yes to link or No to Cancel."
  16. If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new Description?") = vbNo Then
  17. Response = acDataErrContinue
  18. Else
  19. Set Db = CurrentDb
  20. Set rs = Db.OpenRecordset("Miracle_Cloth_Main", dbOpenDynaset)
  21. On Error Resume Next
  22. rs.AddNew
  23. rs!YourField = NewData
  24. rs.Update
  25. rs.Close
  26.  
  27. Set rs = Nothing
  28. If Err Then
  29. MsgBox "An error occurred. Please try again."
  30. Response = acDataErrContinue
  31. Else
  32. Response = acDataErrAdded
  33. End If
  34. End If
  35.  
  36. End Sub
  37.  
  38.  
  39.  
Could someone please help to solve this error
occuring when entering data
Any help will be much appreciated
Nov 8 '06 #1
3 2427
PEB
1,418 Recognized Expert Top Contributor
Hi

Can you disable

On Error Resume Next

And tell us on which line is the error and what just is the error message?
Nov 8 '06 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Set rs = Me.Recordset.Clone

This is incorrect should be ...

Set rs = Me.RecordsetClone

No dot between recordset and clone
Nov 9 '06 #3
valley
35 New Member
Set rs = Me.Recordset.Clone

This is incorrect should be ...

Set rs = Me.RecordsetClone

No dot between recordset and clone
Many thanks for the replies:

The above code was actually created by access while the Combo was created by the WIzard. However I have
changed it to
Set rs = Me.RecordsetClone

But this did not solve the problem or create a new message.

While checking the code I noticed another error

on the line which was left as rs!yourField=NewData

This was corrected to
rs!Name = NewData

Everything seems to work Now.

Many thanks for all the help. Great Forum !!!
Nov 9 '06 #4

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

Similar topics

3
by: Nicolae Fieraru | last post by:
Hi All, I have a problem and I can't figure out how to solve it. My database has three tables: tblCustomers, with CustomerId and CustomerName tblProducts, with ProductId and ProductCode...
5
by: Tim | last post by:
I have block of code adding values to dropdown list under if (!Page.IsPostBack) { adding items } else { refreshing data }
5
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
1
by: Marco Roberto | last post by:
Hi, is there anyway to add itens into a combobox after this control be bound with a dataset? Regards, Marco
6
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
10
by: robingSA | last post by:
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,...
0
by: marcobx | last post by:
I have a ComboBox and a List of objects to popolate items. I use the DataSource property and not the List collection: List<foolst = new List<foo>; //add elements into the list //......
0
by: spowel4 | last post by:
VB 2005: Using an xml file as the data source, I need to fill a listbox with data based upon what was selected in a combobox. In other words, my data consists of a list of customers in a...
0
by: saijin | last post by:
I'm planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything Here's the ActionScript 3.0 import...
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:
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,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.