Mandatory records

G

Guest

Can someone help me understand how to require that a record be put in a table
if a record is put in a related table.

Example: If I am entering a Site Visit in my Site Visit Table, I MUST
include at least one Unit (which I visited) in my related Unit table and my
Unit tbl must have at least on bedroom in the Bedroom tbl related to that
Unit.

The tables seem to be related to each other ok and I have a form that has
sub forms so I can enter all these related things, but I am not sure how to
require related records be entered in related tables.
 
G

Guest

I am a bit confused by your last sentence. What do you want to do? What is
the problem?
 
C

Chris2

knowshowrosegrows said:
Can someone help me understand how to require that a record be put in a table
if a record is put in a related table.

Example: If I am entering a Site Visit in my Site Visit Table, I MUST
include at least one Unit (which I visited) in my related Unit table and my
Unit tbl must have at least on bedroom in the Bedroom tbl related to that
Unit.

The tables seem to be related to each other ok and I have a form that has
sub forms so I can enter all these related things, but I am not sure how to
require related records be entered in related tables.

knowshowrosegrows,

If I am reading your message correctly, you want to make sure that if a record is inserted
into TableA, that a record is also inserted into TableB.

In whatever event of the form or one of its controls, in the event that fires right after
whatever user action determines that data needs to be put in the tables, you would use a
pair of VBA ADO/DAO driven insert statements that would load the tables in question with
the data in question.

If you feel ambitious, you could put the VBA code in a pair of classes (one for each
entity/table involved), instantiate them as objects on the form, and call on the methods
of the objects which would run the insert statements. The same objects would also
encapsulate all other code used to access their associated tables (UPDATE, DELETE,
SELECT). This way, all the code used to access each table is kept in one place (each
class), no matter how many forms it is used on.


Sincerely,

Chris O.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top