PC Review


Reply
Thread Tools Rate Thread

Adding a value to a list box

 
 
=?Utf-8?B?TmlnZWw=?=
Guest
Posts: n/a
 
      9th Jun 2005
In a table I have defined a field as a lookup combo box and added some values
to eg 1,2,3. If on a form the user needs to enter 4 how can I code it so that
value automatically gets added to the filed value list in the table.

Thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      9th Jun 2005
Tailor the following to suit your needs but basically this asks for the new
input, adds it to the table and refreshes the display of the combobox.

Dim strAnswer As String

strAnswer = InputBox("Enter new data for the list", "New Data")
If strAnswer <> "" Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO YourTable (FieldName) VALUES ('" &
strAnswer & "')"
DoCmd.SetWarnings True
YourComboBox.Requery
End If

"Nigel" wrote:

> In a table I have defined a field as a lookup combo box and added some values
> to eg 1,2,3. If on a form the user needs to enter 4 how can I code it so that
> value automatically gets added to the filed value list in the table.
>
> Thanks

 
Reply With Quote
 
=?Utf-8?B?TmlnZWw=?=
Guest
Posts: n/a
 
      9th Jun 2005
How would I add the new value to the row source on the field properties, I
allready have Ship Complete and ship Direct the user adds Ship ASAP to the
How do I get that on the rowsource
"Dennis" wrote:

> Tailor the following to suit your needs but basically this asks for the new
> input, adds it to the table and refreshes the display of the combobox.
>
> Dim strAnswer As String
>
> strAnswer = InputBox("Enter new data for the list", "New Data")
> If strAnswer <> "" Then
> DoCmd.SetWarnings False
> DoCmd.RunSQL "INSERT INTO YourTable (FieldName) VALUES ('" &
> strAnswer & "')"
> DoCmd.SetWarnings True
> YourComboBox.Requery
> End If
>
> "Nigel" wrote:
>
> > In a table I have defined a field as a lookup combo box and added some values
> > to eg 1,2,3. If on a form the user needs to enter 4 how can I code it so that
> > value automatically gets added to the filed value list in the table.
> >
> > Thanks

 
Reply With Quote
 
=?Utf-8?B?TmlnZWw=?=
Guest
Posts: n/a
 
      9th Jun 2005
I have worked out how to add the new value to the rowsource, but the issue I
am having is whatever I enter adds it to the list even if it allready exists,
how can I check to see if the value is allready there and if it is do not add
it

THanks

"Nigel" wrote:

> In a table I have defined a field as a lookup combo box and added some values
> to eg 1,2,3. If on a form the user needs to enter 4 how can I code it so that
> value automatically gets added to the filed value list in the table.
>
> Thanks

 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      9th Jun 2005
If you are allowing additions to the look up then the rowsource should be
based on a tables contents instead of hard coded values. Once you have added
the value to the look up table, the look up rowsource will be automatically
updated.

"Nigel" wrote:

> How would I add the new value to the row source on the field properties, I
> allready have Ship Complete and ship Direct the user adds Ship ASAP to the
> How do I get that on the rowsource
> "Dennis" wrote:
>
> > Tailor the following to suit your needs but basically this asks for the new
> > input, adds it to the table and refreshes the display of the combobox.
> >
> > Dim strAnswer As String
> >
> > strAnswer = InputBox("Enter new data for the list", "New Data")
> > If strAnswer <> "" Then
> > DoCmd.SetWarnings False
> > DoCmd.RunSQL "INSERT INTO YourTable (FieldName) VALUES ('" &
> > strAnswer & "')"
> > DoCmd.SetWarnings True
> > YourComboBox.Requery
> > End If
> >
> > "Nigel" wrote:
> >
> > > In a table I have defined a field as a lookup combo box and added some values
> > > to eg 1,2,3. If on a form the user needs to enter 4 how can I code it so that
> > > value automatically gets added to the filed value list in the table.
> > >
> > > Thanks

 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      9th Jun 2005
The answer depends on whether your row source is hard coded or a lookup to a
tables values.

"Nigel" wrote:

> I have worked out how to add the new value to the rowsource, but the issue I
> am having is whatever I enter adds it to the list even if it allready exists,
> how can I check to see if the value is allready there and if it is do not add
> it
>
> THanks
>
> "Nigel" wrote:
>
> > In a table I have defined a field as a lookup combo box and added some values
> > to eg 1,2,3. If on a form the user needs to enter 4 how can I code it so that
> > value automatically gets added to the filed value list in the table.
> >
> > Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically extend a list when adding a new data to another list JB Microsoft Excel Misc 0 25th Mar 2010 02:50 PM
adding another item to a list of fields coming from a table inside of a list control thread Microsoft Access 8 28th Feb 2007 07:06 PM
Adding Contact and Distribution List Names to a List =?Utf-8?B?Q2xhcmtl?= Microsoft Outlook VBA Programming 1 4th Jan 2005 05:29 PM
OL2002: Adding list of contacts to a Distribution List after search PHiL M. Microsoft Outlook Contacts 9 15th Apr 2004 01:54 PM
Re: Adding file list to list or combo control Michael Daly Microsoft Access Form Coding 0 2nd Sep 2003 07:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 AM.