Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Combo Box Add Item Error

Geek News

Combo Box Add Item Error
"edisonl via AccessMonster.com" <u47544[ at ]uwe> 12/24/2008 6:35:15 AM
Hi everyone, (Merry X'mas in advance)

1. I had a combo Box.RecordSource = Table/Query

2. No problem with retrieving value from query to Combo Box

3. Now Problem, Append value from one of my controls unto Combo Box

4. I tried AddItem But can't achieve (Please see below code)

counter = StaffName_ComboBox.ListCount
counter = counter + 1
StaffName_ComboBox.AddItem UserName_text, counter + 1

5. Anyone able to provide help ?

Edison

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

Re: Combo Box Add Item Error
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 12/24/2008 2:58:45 PM
On Wed, 24 Dec 2008 06:35:15 GMT, "edisonl via AccessMonster.com"
<u47544[ at ]uwe> wrote:

That is indeed not possible because the dropdown is bound to a query.
What is the larger picture of what you are trying to do? Perhaps you
want to add that item to the underlying table (using an Append query),
and then requery the dropdown?

-Tom.
Microsoft Access MVP



[Quoted Text]
>Hi everyone, (Merry X'mas in advance)
>
>1. I had a combo Box.RecordSource = Table/Query
>
>2. No problem with retrieving value from query to Combo Box
>
>3. Now Problem, Append value from one of my controls unto Combo Box
>
>4. I tried AddItem But can't achieve (Please see below code)
>
> counter = StaffName_ComboBox.ListCount
> counter = counter + 1
> StaffName_ComboBox.AddItem UserName_text, counter + 1
>
>5. Anyone able to provide help ?
>
>Edison
Re: Combo Box Add Item Error
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> 12/24/2008 3:01:03 PM
Two questions first:

What error is being raised? You must always includ this when posting a
question!

What version of Access are you using? Th function of AddItem in Access VBA
changed between version 2000 and version 2003. Version 2003 was the first
time that it could be used in the manner you're trying.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

Re: Combo Box Add Item Error
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> 12/24/2008 3:11:54 PM
I just came back to this because it dawned on me that the OP said the cbo was
bound to a query. AddItem (assuming the version is 2003 or later) can only be
used when the Row Source Type is a Value list.

As Tom has said, with a table/query Row Source you'd have to add an item to
the underlying table, then requery the combobox.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

Re: Combo Box Add Item Error
"edisonl via AccessMonster.com" <u47544[ at ]uwe> 12/25/2008 12:27:12 AM
Hi Adams,

Ya I am using Access 2K, erm.. my Query for the combo box was done
programatically (at least something I can Change or Modified Later)

What is hope to achieve : Leave Application, Superior Able to Login & Apply
on behalf of his/her subordinate, therefore my query was as such:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

dim strsql as string

strsql = "SELECT Name FROM Personnel_Table WHERE Approval = '" &
UserName_Text & "'"
StaffName_ComboBox.recordsource = strsql

'This perfectly display all staff name field (inside personnel table) where
another column stated
superior name, filed name as Approval.

PROBLEM: I totally forgot to includes SUPERIOR Name himself, which means
he/she can't apply leave for himself ! lolx

QUESTIONS: If I were to programatically use Append query, what is the syntax
format ?

PS: Merry Xmas 08 :)

Edison








~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"
Linq Adams wrote:
[Quoted Text]
>I just came back to this because it dawned on me that the OP said the cbo was
>bound to a query. AddItem (assuming the version is 2003 or later) can only be
>used when the Row Source Type is a Value list.
>
>As Tom has said, with a table/query Row Source you'd have to add an item to
>the underlying table, then requery the combobox.
>

--
Message posted via http://www.accessmonster.com

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net