Combo Box Add Item Error

  • Thread starter edisonl via AccessMonster.com
  • Start date
E

edisonl via AccessMonster.com

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
 
T

Tom van Stiphout

On Wed, 24 Dec 2008 06:35:15 GMT, "edisonl via AccessMonster.com"

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
 
L

Linq Adams via AccessMonster.com

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.
 
L

Linq Adams via AccessMonster.com

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.
 
E

edisonl via AccessMonster.com

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








~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top