Unanswered: Automatically add a record to a related table help
I would like to automatically add a new record to a table when a record in a related table is added.
I have a form which displays data from a contact details table. When a new contact is added I would like to automatically add an additional new record to a related table which stores the contact type. The contacts table is linked from a central SQL database so for this particular Access database link I would like the group type [GroupTypeID] field to always default to a certain value.
The Contact type table is linked to the Contacts table through the contactID field. The full field list is:
[TypeID] Primary Key, automatic number
[ContactID] Foreign key
ContactID can be grabbed from the contacts form and I can set the GroupTypeID to a default value. However I need a record to actually be added to the ContactType table, not just default values displayed in the form. Ideally the record can be added using an on update or on click event.
Can anyone help me with the code? I have played about with AddNew but with no success.
Just posted another question but worked it out I was typing it. The code worked fine with one value but I was having problems picking up a second value from the input form. Managed to get it to work with:
Dim Myvalue As String
Myvalue = Forms!frmContactsData!ContactID