Autocomplete of Foreign Key fields

dazedandconfused

Registered User.
Local time
Today, 09:21
Joined
Mar 4, 2008
Messages
28
In my database I have 4 different forms that relate to the same pieces of casework. They are 'Person Information', 'Incidents', 'Actions' and 'Outcomes'. The Primary and Foreign keys are set up as follows:

Person Information - IPSOref (PK)
Incidents - IncidentID (PK), IPSOref (FK)
Actions - ActionID (PK), IncidentID (FK)
Outcomes - OutcomeID (PK), IncidentID (FK)

Obviously the Person Info form is the first form completed when entering a new record. All the other forms have a relationship linked to this form. My question is - how do I get Access to automatically complete the Foreign Key fields when they are opened within that specific record?
 
If you use "subforms" they are autofilled... without you doing anything (after setting up the subform offcourse)

You could also (if you like) use the "OpenArgs" argument of the docmd.openforms if you are allready using that.
 
If you use "subforms" they are autofilled... without you doing anything (after setting up the subform offcourse)

You could also (if you like) use the "OpenArgs" argument of the docmd.openforms if you are allready using that.

How do I do that exactly?
 
Lookup the Openform in the help for details... because there is more stuff you can use like the view, datamode, window option, really a good thing to know about.

Becuase the sample doesnt explain the Openargs very well..

Basicaly what you do:
docmd.OpenForm ( "FormName", ,,,,,"OpenArgs")

Then in the form you opened you can use
Me.Openargs to retrieve any value(s) passed along in the "OpenArgs" and do anything with it, like fill FKs...

docmd.OpenForm ( "FormName", ,,,,,1) would pass along the value 1
Me.SomeForeignKey = Me.Openargs
Would fill the FK with 1...
 

Users who are viewing this thread

Back
Top Bottom