Opening a form via a subform

  • Thread starter Thread starter Toby Gallier
  • Start date Start date
T

Toby Gallier

I have a form that has no actual infomration in it.. its being used as
my launch screen so it has a bunch of buttons that open other forms. in
this "launch" form i want to put an existing "data" form in as a
subform. this "data" form has a list of records, each record has a view
button to open another form and populates based on the selected
record, providing more details.. lets call this the "detail" form.
This "data" form works fine on its own, you click the view button, the
"detail" form opens with data for the selected record in the "data"
form.

However when i add the "data" form as a sub form into my "launch" form,
it displays the "data" form just fine. When I push the view button on
the "data" subform, to launch the "details" form it wont open and asks
for the parameter that is passed between the "data" form and the
"detail" form.

any ideas?

Thanks!
 
Toby,

A bit hard to follow but I'll try:

If you pass parameters from the 'data' form by itself which refers to data
form eg Forms![dataForm]! etc, you will need to amend the code when your
'data' form is in fact a subform eg:
Forms![LaunchForm]![DataForm]! etc.

Or, if this is the case, pass the parameters as memory variable, in which
case they will be independent of whether you 'data' form is a form or a
subform eg:

Suppose you want to pass the ID of the 'data' form:
(in the data form)

Private Sub ViewButton_Click()
dim idData as long, strFrom as String

idData=Nz(Me.Data_ID,0)
strFrom="DetailForm"

Docmd.OpenForm strForm
DoCmd.SelectObject acForm, strForm

if idData=0 then
'No ID Open new Record
DoCmd.GotoRecord,,acnewRec
else
'Find the ID
DoCmd.GoToControl "Detail_ID"
DoCmd.FindRecord idData
End If
DoCmd.goToContol "Whatever"

End Sub

Or do something similar using OpenArgs

Regards/JK
 
Possible causes:

1. In the DoCmd.OpenForm ... statement (to open the Form "frmDetail"), you
referred to a Field or Control on the Form "frmData" (using the full
reference like Forms!frmData.FieldOrControl) to filter (?) the RecordSource
of the Form "frmDetail".

2. If you don't use the above, you might have a criterion in the
RecordSource or a Form Filter for the Form "frmDetail" that refers to a
Field or a Control on the Form "frmData" (using full reference)

This refernce will work fine if you open the Form "frmData" by itself but
won't work if the "frmData" is opened as the Subform of the Form
"frmLaunch".

Find out this reference and see if you can fix it using the info from The
Access Web article:

http://www.mvps.org/access/forms/frm0031.htm

If you can't, post what you find here ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top