[AccessD] Create subform record when form record is created

Arthur Fuller fuller.artful at gmail.com
Mon Jan 26 07:48:03 CST 2009


Assuming that you have a Save button on the tblEvents form, then couldn't
you just add code similar to this?

<vba>
Dim sql as String
Dim intParentID as Integer
intParent = Me.EventID
sql = "Insert Into tblEventSectionLeft (EventID, Status) VALUES (" +
intParentID + ", 'A'")
DoCmd.RunSQL sql
'and repeat for the other two tables
</vba>
Or am I missing something?
Arthur
On Sun, Jan 25, 2009 at 6:37 PM, Bob Gajewski <rbgajewski at roadrunner.com>wrote:

> This question is for an event ticket sales application (with assigned
> seating).
>
> I have one main table (tblEvents) for the header information (name, date,
> time, etc.).
>
> I have three section tables (tblEventSectionLeft, tblEventSectionMiddle,
> and
> tblEventSectionRight) for the ticket sales information. This was necessary
> due to the number of fields required. This contains the status of each
> auditorium seat (A=Available, R=Reserved, S=Sold). Each of the 3 section
> tables is related to the main table, with referential integrity for cascade
> update and cascade delete enforced.
>
> Normal data entry using a form with three subforms works as expected.
>
> I also have a report that includes main table information and 3 subreports.
>
> My problem is that when I try to print a report but have not yet entered
> any
> data in one or more of the section tables, I get error 2455. This is
> because
> only main table (header) information has been entered; no section table
> records exist. But, since all fields in each of the 3 related tables have
> default values (they all default to "A"), my question is this -
>
> How do I automatically create the 3 related section table records as soon
> as
> a main table record exists?
>
> As always, I appreciate any suggestions.
>
> Best regards,
> Bob Gajewski
>
> P Please consider the environment before printing this e-mail
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



More information about the AccessD mailing list