Nov 5 2007, 01:45 PM
I have a form that pulls Action information from Table 1 using a combo box to select a record.
This record can than have multiple 'document' records that are stored in Table 2 (1-to-many relationship with Table 1) which I have displayed in a subform on the main form. If not 'documents' exist for the selected record than nothing is displayed in the subform.
I'm new to VBA so I'm trying to figure out how can I use a command button to allow the user to add a new document (or documents) and have this data stored (added) in Table 2?
The two tables are linked using the primary key 'CA_Key' field.
Edited by: KROUTD on Mon Nov 5 13:49:44 EST 2007.
Nov 5 2007, 01:52 PM
The user can enter the data directly into the controls in the subform...
Nov 5 2007, 02:08 PM
I thought the same thing but the controls on the subform are grayed out and there's no blank (white) field to enter any data. Is it possible I have a setting incorrect on the subform?
Nov 5 2007, 02:12 PM
Make sure each controls Enabled property is set to Yes, that the Forms Allow Edits, Allow Additions and Allow Deletions are set to Yes. Data Entry should be set to No...
Nov 5 2007, 02:18 PM
Nov 5 2007, 02:23 PM
And you are saying that you do not have access to these controls? Have you tried making a new subform, from scratch, and deleting the old one and then adding in the new one? Can you add data to the subform directly outside of the main form?
The behaviour you described is consistent with empty Recordset for the Subform and either:
* The AllowAdditions Property of the Subform (SourceObject) is set to No / False or
* The RecordSource for the Subform is not updatable hence addition is not possible.
Check the RecordSource of of the Subform and make sure it is updateable.
Nov 6 2007, 08:20 AM
In the subform I have the 'AllowAdditions' property set to 'Yes' and the RecordSource is updateable (I'm simply selecting fields from a table). Your comment about an empty Recordset made me think a little more. Here's the situation:
- Table 1 - contains all of my 'Action' Records
- Table 2 - only contains records if there is a 'document' associated with the Action.
If I'm viewing a record from Table 1 that has an associated document (record in Table 2) I see those records and I'm able to scroll through the records if there's more than 1. But the >* button is grayed out so I can't add a new record to the list.
If I'm viewing a record from Table 1 that does not have an associated document (no records in Table 2) I don't see anything and all the controls at the bottom of the screen are grayed out.
I was trying to use a command button to allow me to add a record into Table 2. Would this be the best way to do this? Or should I be trying something else?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here