Open sub forms with linked record if it exists, otherwise a new record

  • Thread starter Thread starter aeilie
  • Start date Start date
A

aeilie

I have a main form with several sub forms as pop ups. Each is linked
to a seperate table, all of which are linked by ID.

I would like the subforms to open on the relevant record, if it
exists, but otherwise as a new record (recording the ID from the main
form).

Can anyone help?
 
aeilie said:
I have a main form with several sub forms as pop ups. Each is linked
to a seperate table, all of which are linked by ID.

I would like the subforms to open on the relevant record, if it
exists, but otherwise as a new record (recording the ID from the main
form).


The Link Master/Child properties are normally used for this.
Have you tried using them? if you did, what went wrong?
 
Marshall Barton said:
The Link Master/Child properties are normally used for this.
Have you tried using them? if you did, what went wrong?

Thanks for your suggestion. The problem is I need these forms to be
pop-up forms. I have created them as standard forms, for data entry,
opened either by a command button or from the 'onClick' event of a
check box on the main form.

There is no space for subforms to be embedded on the main form. The
main form contains information users will reference while filling the
'sub' forms.

I guess I might be missing something elementary here. My only
solution so far has been to pass IDs between forms for synchronising
them and I havn't been able to come up with a method for opening the
form on a new record if no linked record exists.
 
aeilie said:
Thanks for your suggestion. The problem is I need these forms to be
pop-up forms. I have created them as standard forms, for data entry,
opened either by a command button or from the 'onClick' event of a
check box on the main form.

There is no space for subforms to be embedded on the main form. The
main form contains information users will reference while filling the
'sub' forms.

I guess I might be missing something elementary here. My only
solution so far has been to pass IDs between forms for synchronising
them and I havn't been able to come up with a method for opening the
form on a new record if no linked record exists.

How about opening the related forms to just the related
records, instead of positioning the form to the record(s) of
interest? This is easy to do by using the OpenForm method's
WhereCondition argument.

As long as the related forms are not restricted to just
editing existing records, the new record area will always be
there, so, if there are no existing related records, the new
record area will be the only thing displayed.

Maybe I'm missing the point of your problem because I just
don't see anything tricky here??
 
You're right, I was reinventing the wheel. Thanks for considering the
problem. It seems a common stumbling block, from searching the
forums, so for the record I used this code, in the onClick event of a
check box:

Dim stDocName As String
Dim stLinkCriteria As String

If chkTheme1 = -1 Then 'So it opens when the check is filled, not
unfilled

stDocName = "Priority1entry" 'Name of Form to open

stLinkCriteria = "[actID]=" & Me![actID] 'actID is the linking
field
DoCmd.OpenForm stDocName, , , stLinkCriteria

aeilie
 
Thank you for posting this. I was looking for this information as well. It
looks as though you are doing the exact same thing I am. Thanks again.

aeilie said:
You're right, I was reinventing the wheel. Thanks for considering the
problem. It seems a common stumbling block, from searching the
forums, so for the record I used this code, in the onClick event of a
check box:

Dim stDocName As String
Dim stLinkCriteria As String

If chkTheme1 = -1 Then 'So it opens when the check is filled, not
unfilled

stDocName = "Priority1entry" 'Name of Form to open

stLinkCriteria = "[actID]=" & Me![actID] 'actID is the linking
field
DoCmd.OpenForm stDocName, , , stLinkCriteria

aeilie

Marshall Barton said:
How about opening the related forms to just the related
records, instead of positioning the form to the record(s) of
interest? This is easy to do by using the OpenForm method's
WhereCondition argument.

As long as the related forms are not restricted to just
editing existing records, the new record area will always be
there, so, if there are no existing related records, the new
record area will be the only thing displayed.

Maybe I'm missing the point of your problem because I just
don't see anything tricky here??
 
Back
Top