Adding new values to combo boxes (overriding the item not in list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Only new to VBA but have a combo box that i would like to able to add new
data (names) to without getting the error "item not in list". I can currently
open a new name data entry form, add the name then return, but this is not
convenient. I would prefer to add straight into the combo box field (perhaps
with just a warning message). Im new to vba so a step by step procedure is
necessary.
So far i believe that an event is attached to the OnNotInList property. Ive
tried one procedure but couldn't get it to work. Also beleive that it is
necessary to declare "references" in the vba module- a quick run down on this
might be good too as ive tried it with no luck. Your help on i guess, a basic
topic would be great.
 
Thanks mate, Have been reading and trying unsuccessfully for weeks but this
works. In the process of updating all my databases with this.

By the way, can you recommend any descent courses on Access, Im relatively
new at databases (but work in the scientific field) but would like to get
into slightly more, especially the automation side.
Thanks
Chris
 
Graham,
You suggested worked great for something I was working on. I was curious
though after choose to add the item not on list by clicking YES the record
count at the bottom of the screen remains the same instead of increasing by
one. Can you advise how to get it to update?
 
I don't understand your scenario. The code updates a table, presumably a
table that is different to the one the form is bound to. Unless your form is
bound to the same table, the RecordCount won't be updated. If it is, just
issue a Me.Refresh.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
Before we get into that, tell us what you're trying to do, and how you're
trying to do it, in as much detail as you can. In that way, we can offer
informed suggestions.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
I was utilizing the OnNotOnList so when I got to a field on my form to enter
a new record if the ItemID I was entering didn't already exist in the Item
Table then it would be added. The items is added to the table but when the
record count doesn't change I'm not really confident that it in fact was
added.
 
Presumably the records shown in the combo list are stored in a different
table to those shown on the rest of the form. So if you create a new record
in one table, the RecordCount for the other table is, naturally, unaffected.

But I have a funny feeling you're trying to enter the primary key itself. Is
that's true, then I think you need to give us a little more information.
What I would like to know is:
* The name of the table to which the form is bound, and the name of the
primary key and any relevent fields in this table.
* The name of the table to which the combo is bound, and the name of the
primary key and any relevent fields in this table.
* The RowSource property of the combo, its ControlSource, and
BoundColumn.
* The name of the field you're trying to enter into the combo, how
you're trying to enter it, and the relationship this field has to the form.

I know this seems like I'm asking a lot of questions, but you haven't been
very forthcoming with detailed information, and we need to understand your
situation in order to help you.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
Back
Top