Opening Form from Subform

J

Joe Williams

I am trying to code a subform so that double clicking on a subform record
brings up a new form for that particular record. I am putting the following
code in the double click event:

DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!MattecDL!MattecDLSub.Form!jobno", acFormEdit

The new form to be opened is called MattecDLDet, the main form is called
MattecDL, the subform for that main form is MattecDLsub. The field I am
trying to reference is called jobno.

The problem I am having is that when I execute the code it gives me the
following message: Enter Paramter Value:
Forms!MattecDL!MattecDLSub.Form!jobno. So it seems as though it cannot
locate the field on the form. I am sure it has something to do with how I am
referencing the subform but I cannot figure it out. I have also just tried
to use "[jobid] = me!jobno" with similar problems.

Please help!
 
T

TomU

Your reference to the control in the subForm in the filter criteria is
incorrect. It should be something like:
DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!FormMain!MattecDL!MattecDLSub!jobno", acFormEdit
where FormMain is the name of the subForm's parent.

TomU
 
J

Joe Williams

Tom,

Thanks for the reply. In my example, MattecDL is the sub form's parent and
MattecDLSub is the sub form. MattecDLDet is the new form I am trying to open
to the record that is on the subform. Am I still referencing it
incorrectly? From you example it would seem you are saying to double
reference the main form....

Thanks

- joe

TomU said:
Your reference to the control in the subForm in the filter criteria is
incorrect. It should be something like:
DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!FormMain!MattecDL!MattecDLSub!jobno", acFormEdit
where FormMain is the name of the subForm's parent.

TomU

Joe Williams said:
I am trying to code a subform so that double clicking on a subform record
brings up a new form for that particular record. I am putting the
following
code in the double click event:

DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!MattecDL!MattecDLSub.Form!jobno", acFormEdit

The new form to be opened is called MattecDLDet, the main form is called
MattecDL, the subform for that main form is MattecDLsub. The field I am
trying to reference is called jobno.

The problem I am having is that when I execute the code it gives me the
following message: Enter Paramter Value:
Forms!MattecDL!MattecDLSub.Form!jobno. So it seems as though it cannot
locate the field on the form. I am sure it has something to do with how I
am
referencing the subform but I cannot figure it out. I have also just
tried
to use "[jobid] = me!jobno" with similar problems.

Please help!
 
T

TomU

My mistake. It should read:
DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!MattecDL!MattecDLSub!jobno", acFormEdit"

You can bracket the object names but I believe that is optional:
DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
[Forms]![MattecDL]![MattecDLSub]![jobno]", acFormEdit"

Joe Williams said:
Tom,

Thanks for the reply. In my example, MattecDL is the sub form's parent and
MattecDLSub is the sub form. MattecDLDet is the new form I am trying to open
to the record that is on the subform. Am I still referencing it
incorrectly? From you example it would seem you are saying to double
reference the main form....

Thanks

- joe

TomU said:
Your reference to the control in the subForm in the filter criteria is
incorrect. It should be something like:
DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!FormMain!MattecDL!MattecDLSub!jobno", acFormEdit
where FormMain is the name of the subForm's parent.

TomU

Joe Williams said:
I am trying to code a subform so that double clicking on a subform record
brings up a new form for that particular record. I am putting the
following
code in the double click event:

DoCmd.OpenForm "MattecDLDet", , , "[jobid] =
Forms!MattecDL!MattecDLSub.Form!jobno", acFormEdit

The new form to be opened is called MattecDLDet, the main form is called
MattecDL, the subform for that main form is MattecDLsub. The field I am
trying to reference is called jobno.

The problem I am having is that when I execute the code it gives me the
following message: Enter Paramter Value:
Forms!MattecDL!MattecDLSub.Form!jobno. So it seems as though it cannot
locate the field on the form. I am sure it has something to do with how I
am
referencing the subform but I cannot figure it out. I have also just
tried
to use "[jobid] = me!jobno" with similar problems.

Please help!
 

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

Top