473,513 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

append combobox values

Hello Everybody (anybody)?

I am trying to appent a combobox to include data entered by a user
which is Not In List. I have came accross this code from Allen Browne
which seems to be what I am looking for can anybody tell me if I have
to change any of the code below to match field names or combobox name
from my own database.

Thanks in advance for any help with this topic?
Function Append2Table(cbo As ComboBox, NewData As Variant) As Integer
On Error GoTo Err_Append2Table
' Purpose: Append NotInList value to combo's recordset.
' Assumes: ControlSource of combo has the same name as the foreign
key field.
' Return: acDataErrAdded if added, else acDataErrContinue
' Usage: Add this line to the combo's NotInList event procedure:
' Response = Append2Table(Me.MyCombo, NewData)
Dim rst As DAO.Recordset
Dim sMsg As String
Dim vField As Variant ' Name of the field to append to.

Append2Table = acDataErrContinue
vField = cbo.ControlSource
If Not (IsNull(vField) Or IsNull(NewData)) Then
sMsg = "Do you wish to add the entry " & NewData & " for " &
cbo.Name & "?"
If MsgBox(sMsg, vbOKCancel + vbQuestion, "Add new value?") =
vbOK Then
Set rst = CurrentDb.OpenRecordset(cbo.RowSource)
rst.AddNew
rst(vField) = NewData
rst.Update
rst.Close
Append2Table = acDataErrAdded
End If
End If

Exit_Append2Table:
Set rst = Nothing
Exit Function

Err_Append2Table:
MsgBox "Error " & Err.Number & ": " & Err.Description,
vbInformation, "Append2Table()"
Resume Exit_Append2Table
End Function

Nov 13 '05 #1
1 2032
St************@dumgal.gov.uk wrote:
Hello Everybody (anybody)?

I am trying to appent a combobox to include data entered by a user
which is Not In List. I have came accross this code from Allen Browne
which seems to be what I am looking for can anybody tell me if I have
to change any of the code below to match field names or combobox name
from my own database.

Thanks in advance for any help with this topic?


[code snipped for brevity]

No, you'd only have to supply your own names in the NotInList event
procedure, e.g.

(air code)
Sub MyCombo_NotInList(NewData As Variant, Reponse As Integer)
' Reponse = (now I wish I hadn't snipped that code
' gotta look elsewhere) :-)
Reponse = Append2Table(MyCombo, NewData)
End Sub
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
4519
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
4
4602
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
2845
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
1
2059
by: amber | last post by:
I'm having an issue with a combobox that is making no sense to me at all. I have a form with several comboboxes/textboxes. The values in these boxes are based on a datarowview, which is based on...
2
8649
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
0
886
by: Chris | last post by:
I have a combobox databound to an interger column in a datatable. I have it set to append but the append doesn't work the way I want. I have the following items in the combobox: 155 196 1195...
6
5276
by: =?Utf-8?B?U2NvdHQgTGFt?= | last post by:
Hi, Is there any way to access the values (not display names)of a combobox ? For example: combo1.DataSource = dataset1.tables(0) combo1.DisplayMember = "Name" combo1.ValueMember = "ID"
0
1065
by: nedier26 | last post by:
Hi everyone, I have a control array that contains two ComboBox and I used a Select Case to make the difference between the ComboBox and I also diferentiate the two ComboBox using their Index...
3
2349
by: Gerhard | last post by:
Hi I have a combobox on a form which gets it's Row Source from a table. I then use an Append Query to save the selected data in the combobox to a file. Everything works fine. The Combobox's...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7373
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
7432
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...
1
7094
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...
0
7519
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
5677
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,...
0
4743
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...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
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...

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.