OpenArg help

  • Thread starter Thread starter Walter
  • Start date Start date
W

Walter

How do I write the code to bring the primary key field of
my main form into the foreign key field of the subform
which is being opened with a command button on the main
form?
DoCmd.OpenForm strDocName,,,strLinkCriteria,,,?
Thanks,
Walter
 
Walter

Sounds like an atypical mainform/subform arrangement. Usually, adding a
subform to a mainform includes setting the "parent" and "child" fields, and
the subform "inherits" the primary key when you enter a record in the
subform. Of course, if the table/query on which your subform is based does
not include the foreign key field, there'd be no way to connect.
 
1. You pass the OpenArg value as the 7th parameter of the
DoCmd.OpenForm statement. It should be remembered that
it is always treated as a string.
2. In the form being opened, you write code to process the
OpenArg parameter (usually in the Form's Load event
handler). You reference the parameter by means of the
predefined variable OpenArgs.
e.g. strForeignKey = OpenArgs

Hope That Helps
Gerald Stanley MCSD
 
1. You pass the OpenArg value as the 7th parameter of the
DoCmd.OpenForm statement. It should be remembered that
it is always treated as a string.

Not so. It is a variant with string subtype. It will receive Null if the
caller does not pass a value, or passes Null explicitly, or passes a
zero-length string(!)

TC

(snip)
 
Back
Top