Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

multiple primary key tables

6 views
Skip to first unread message

Ang

unread,
Sep 18, 2002, 2:31:35 PM9/18/02
to
I am having a problem adding new records to a table with 2
PK's in it through code. The DoCmd.GoToRecord method is
not working to add a new record to the table. Any
suggestions?

Earl Lewis

unread,
Sep 18, 2002, 3:43:12 PM9/18/02
to
Ang,

Records are usually added to Access databases via forms, especially when
your trying to do so via code. Are you using a form? Or are you entering
your data into a table view? If you're using a table view to do your data
entry there are no event procedures available to tables to trigger any code.

As long as you're trying to do it with a form try:

DoCmd.GoToRecord acDataForm, "YourFormName", acNewRec

All this code will do is move the user to an empty (new) record so they can
enter data in the form. It *will not* add any data to the underlying table.

BTW, the compound primary key has nothing to do with why this is not
working.

HTH

Earl Lewis


"Ang" <aswo...@lorman.com> wrote in message
news:249b01c25f41$9e99aea0$35ef2ecf@TKMSFTNGXA11...

John Vinson

unread,
Sep 18, 2002, 3:48:06 PM9/18/02
to

Well... a couple of questions here.

A Table can have one and only one Primary Key. That Primary Key might
consist of one field, or two fields, or ten fields - but it's only ONE
primary key.

And the DoCmd.GoToRecord method is not designed to add a new record to
anything. It opens up the new record, and allows a user to enter data
into that record - but it does not by itself create a record.

Could you explain a bit more about what you want to happen? How are
the values of the two fields that (apparently) make up your primary
key determined? Do you want them automatically generated, user
entered, or what? And... most importantly... what symptoms do you see
that indicate it's "not working"?


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public

0 new messages