why does it ask me to add ID number

  • Thread starter Thread starter Carla
  • Start date Start date
C

Carla

Hi, my database has a main table called OBS ID with a primary key called
OBS_ID with is a foreign key in the following tables: Counter Measures,
Critical Behaviours, Critical conditions, Well_Dones.

I have created a data entry form to add data to my main table with buttons
that you click if you need to add data to one of the above mentioned tables
(not always the case). When I click the button to open any one of the 4 four
forms based on the above mentioned tables, the form won't let me save because
it wants be to add the OBS_ID data. I assumed that this would just fill in
correctly because all the tables are linked with a one to many relationship
back to the main table. How can I fix this so that the data is being added to
the OBS_ID that is on my main form?
 
This will only happen automatically when you are using a subform to add data
to one of the other 4 tables.

You can use subforms, or an alternative is to supply the OBS_ID for each of
the other forms when you open them.
You can use OpenArgs to pass the value of OBS_ID from the main form to one
of the other forms when you open it from the main form.

Something like this
DoCmd.OpenForm [NameOfForm], , , , , ,Me.OBS_ID

Then on the open event of the form being opened you can put

If Not IsNull Me.OpenArgs Then
Me.OBS_ID.DefaultValue = Me.OpenArgs
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Hi, my database has a main table called OBS ID with a primary key called
OBS_ID with is a foreign key in the following tables: Counter Measures,
Critical Behaviours, Critical conditions, Well_Dones.

I have created a data entry form to add data to my main table with buttons
that you click if you need to add data to one of the above mentioned tables
(not always the case). When I click the button to open any one of the 4 four
forms based on the above mentioned tables, the form won't let me save because
it wants be to add the OBS_ID data. I assumed that this would just fill in
correctly because all the tables are linked with a one to many relationship
back to the main table. How can I fix this so that the data is being added to
the OBS_ID that is on my main form?

A relationship between tables does NOT automagically add records or field
values to your table. When you use a command button to open a separate form,
that form has no way to know where it's been called from or what the current
Obs ID is on some *other* form.

Rather than a button opening a separate form, you can put these four forms on
the main form as Subforms (they can be on individual pages of a Tab Control if
you don't want the screen all cluttered). Make the Master Link Field and Child
Link Field of each subform [Obs ID] and it will cause the subform to inherit
the current value on the mainform.
 
Back
Top