PC Review


Reply
Thread Tools Rate Thread

Custom Combo Box

 
 
=?Utf-8?B?QW5uZW1hcmll?=
Guest
Posts: n/a
 
      5th Sep 2006
How can I create a combo box where I can enter in data and have it save the
data I entered for later use? For example. I have a "requested by" field. I
want to enter in Jim Bob, and have it remember Jim Bob so when I need to use
that name again, it is already avalable?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      5th Sep 2006
You mean "Jim Bob" is a name that is not yet in a list of names that the
combo box could look up, but rather a new name that you would like to add to
such a list?

"Annemarie" wrote:

> How can I create a combo box where I can enter in data and have it save the
> data I entered for later use? For example. I have a "requested by" field. I
> want to enter in Jim Bob, and have it remember Jim Bob so when I need to use
> that name again, it is already avalable?

 
Reply With Quote
 
=?Utf-8?B?QW5uZW1hcmll?=
Guest
Posts: n/a
 
      5th Sep 2006
Yes



"Niniel" wrote:

> You mean "Jim Bob" is a name that is not yet in a list of names that the
> combo box could look up, but rather a new name that you would like to add to
> such a list?
>
> "Annemarie" wrote:
>
> > How can I create a combo box where I can enter in data and have it save the
> > data I entered for later use? For example. I have a "requested by" field. I
> > want to enter in Jim Bob, and have it remember Jim Bob so when I need to use
> > that name again, it is already avalable?

 
Reply With Quote
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      5th Sep 2006
You could try to use "Requery Action" - look up the details in Help. If that
works manually, it can probably be automated, too. But you'll need a more
experienced person to help you with that, I'm afraid.

Good luck.

"Annemarie" wrote:

> Yes
>
>
>
> "Niniel" wrote:
>
> > You mean "Jim Bob" is a name that is not yet in a list of names that the
> > combo box could look up, but rather a new name that you would like to add to
> > such a list?
> >
> > "Annemarie" wrote:
> >
> > > How can I create a combo box where I can enter in data and have it save the
> > > data I entered for later use? For example. I have a "requested by" field. I
> > > want to enter in Jim Bob, and have it remember Jim Bob so when I need to use
> > > that name again, it is already avalable?

 
Reply With Quote
 
William Hindman
Guest
Posts: n/a
 
      6th Sep 2006
....the simplest way is to bind the control to a field and set the control's
"Limit to List" property to no ...it will let you type anything into the
box, or select from the current list, and save it so long as it doesn't
conflict with any validation criteria you set.

....next up is to set "Limit to List" property to yes and provide vba code
for the control's NotInList event to control what can be entered and how
....this would normally pop up a dialog giving the user choices and
responding to their input based upon your event code. .

....and if your skill level is up to it, you can use unbound forms to
accomplish the same thing with even more control over what happens.

....hth

William Hindman

"Annemarie" <(E-Mail Removed)> wrote in message
news:A436B775-A813-4181-83A7-(E-Mail Removed)...
> How can I create a combo box where I can enter in data and have it save
> the
> data I entered for later use? For example. I have a "requested by" field.
> I
> want to enter in Jim Bob, and have it remember Jim Bob so when I need to
> use
> that name again, it is already avalable?



 
Reply With Quote
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      6th Sep 2006
Ok, I got this to work in a simple test database.

First, I created a query on the table that pulls out the names. Then I set
my combo box to be based on that query. Then I made a macro: the action is
"Requery", and in the Control Name field at the bottom I put "names" - the
name of the field in the query with all the names. After that, I went to the
form that holds the combo box, and opened its property sheet. For the "On
Current" field [first one actually] I selected my macro - "requery", and that
was basically it.
Now I can enter a new name into the combo box, and it will be available for
the next new record.

"Niniel" wrote:

> You could try to use "Requery Action" - look up the details in Help. If that
> works manually, it can probably be automated, too. But you'll need a more
> experienced person to help you with that, I'm afraid.
>
> Good luck.
>
> "Annemarie" wrote:
>
> > Yes
> >
> >
> >
> > "Niniel" wrote:
> >
> > > You mean "Jim Bob" is a name that is not yet in a list of names that the
> > > combo box could look up, but rather a new name that you would like to add to
> > > such a list?
> > >
> > > "Annemarie" wrote:
> > >
> > > > How can I create a combo box where I can enter in data and have it save the
> > > > data I entered for later use? For example. I have a "requested by" field. I
> > > > want to enter in Jim Bob, and have it remember Jim Bob so when I need to use
> > > > that name again, it is already avalable?

 
Reply With Quote
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      6th Sep 2006
Only trouble is, you'll get a new record every time you enter a name, so you
can end up with a lot of duplicates. I suspect that's not a problem for your
table, but of course you don't want your combo-box to be cluttered. Therefore
you also need to set the "Unique Values" field on your query's property sheet
to "Yes".

"Niniel" wrote:

> Ok, I got this to work in a simple test database.
>
> First, I created a query on the table that pulls out the names. Then I set
> my combo box to be based on that query. Then I made a macro: the action is
> "Requery", and in the Control Name field at the bottom I put "names" - the
> name of the field in the query with all the names. After that, I went to the
> form that holds the combo box, and opened its property sheet. For the "On
> Current" field [first one actually] I selected my macro - "requery", and that
> was basically it.
> Now I can enter a new name into the combo box, and it will be available for
> the next new record.
>
> "Niniel" wrote:
>
> > You could try to use "Requery Action" - look up the details in Help. If that
> > works manually, it can probably be automated, too. But you'll need a more
> > experienced person to help you with that, I'm afraid.


 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgSGliYnM=?=
Guest
Posts: n/a
 
      6th Sep 2006
Annemarie

Assuming your combo box is called Requested By and your table that holds the
names is called tblNames with a field name of UserName just do the following
:-

Enter tblNames in the RowSource property of the combo box. However, if you
want the names to be sorted you will need to use a query here.
Set the NotInList property to Yes

Enter the code below in the AfterUpdate and NotInList events of the combo box.

Private Sub Requested_By_AfterUpdate()
Requested_By.Requery
End Sub

Private Sub Requested_By_NotInList(NewData As String, Response As Integer)

Response = acDataErrContinue
Requested_By.Undo
If MsgBox("This name is not in the list, would you like to add it to the
list?", vbQuestion + vbYesNo, "Update Names List") = vbYes Then
CurrentDb.Execute "INSERT INTO tblNames (UserName) VALUES ('" &
NewData & "')"
Refresh
Requested_By= NewData
Else
Requested_By= NewData
Refresh
End If
End Sub

--
Peter Hibbs


"Annemarie" wrote:

> How can I create a combo box where I can enter in data and have it save the
> data I entered for later use? For example. I have a "requested by" field. I
> want to enter in Jim Bob, and have it remember Jim Bob so when I need to use
> that name again, it is already avalable?

 
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
Combo box on a custom toolbar susiew32 Microsoft Access VBA Modules 0 25th Feb 2008 03:29 PM
Combo Box Values in Custom Form =?Utf-8?B?dGhlcXVpZXRET01JTk8=?= Microsoft Outlook Form Programming 23 17th Sep 2007 06:46 PM
custom menubar combo box Toxalot Microsoft Access 2 18th Aug 2007 08:46 PM
Custom combo box prompting =?Utf-8?B?bXNjZXJ0aWZpZWQ=?= Microsoft Access Form Coding 1 20th Feb 2007 09:34 PM
Custom drop down combo box NickP Microsoft VB .NET 0 17th Aug 2006 01:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:52 AM.