load new form to have same ID as parent form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Maybe I'm thinking too complicated. I have two records. Personal and
medication. both are controlled by booking number. The personal booking
number is an autonumber, and the medications booking number is just a number.
On my form "Personal" I have a button to open "Meds" How can I open the
"meds" form that matches the personal form? I know how to do it if both
records exist, but the "meds" record for that person does not exist yet. Not
all "personal" will need to use the "meds" form. Basically, how can I get it
to auto fill the booking number on the meds form to match the booking number
of the personal form, and only create a new record the first time it's
clicked, allowing additions to the same record later? Please tell me it's not
as hard as I've been struggling with it.

If this is covered somewhere, I couldn't find it. I've looked for two days.
I don't know a bit of code, so if it's possible to do it in a macro, that
would be REALLY great.
 
Instead of a second form, why don't you use a subform to add records. There
is even a wizard to help you connect them. Just go into Design View of the
"Personal" form and click on the subform button on the Tools toolbar. The
wizard will guide you through it.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
assuming that you have a PersonalID or somesuch as a foreign key in your
"Meds" table linking it to your "Personal" table, use the where clause of
your DoCmd.OpenForm,,,WhereCondition:="[PersonalID]=" & Me.PersonalID to
open the filtered Meds_Form. And to autofill the PersonalID in the
Meds_Form, you can do a number of things:

1. in the OpenArgs clause from your calling form, pass the PersonalID
and in the On Load event of Meds_Form, check for OpenArgs. If not null,
then: Me.PersonalID = Me.OpenArgs

2. in the On Load event of Meds_Form, use the Isloaded() function to check
whether Personal_Form is open. If so, then Me.PersonalID =
Forms!Personal_Form!PersonalID

HTH,
Brian
 
Back
Top