Adding value to lookup table through combo box

  • Thread starter Thread starter Brian Hoffman
  • Start date Start date
B

Brian Hoffman

I would like to type a new value into a combo box to be entered into a lookup
table. Here are the details:

tbl1 (Text Field, PK auto#)
tbl2 (FK, Text Field, PK auto#)
Form: Bound to tbl2.
tbx to enter new value in Text Field
cbo to select/enter FK

I am attempting to use code found on Allen Browne's website
(http://allenbrowne.com/ser-27-01.html), but I am having trouble with it. He
explains in the article that his technique is specific to lookup tables with
a single field. Could tbl1 be the issue since it has the PK auto# as well?

Also, the vfield variant in his code is confusing me. I am having trouble
understanding if I have defined it properly. In my debugging, it appears to
run correctly until the line "rst(vField) = NewData". At this point Error
3265 appears.
 
Hi Brian,

The vField is simply the name of the field in your Table. Apparently you
have something else there inside the parentheses or you were trying to update
the PK Autonumber field which cannot be done this way.

If tbl1 is just a lookup table there should be only unique values in your
Text Field. If that is true then you have no need for an Autonumber field so
just delete it. Then make set your Text Field as the PK.

Let us know how it works out.

Best Regards,
Patrick Wood
http://gainingaccess.net/
 
Thanks Patrick.

I have questioned my decision to use the auto# before, but since I had
already used it I didn't bother removing it. As suspected, by removing the
auto# field the code works as it should.
 
Back
Top