Cannot find Form Error

G

Guest

I have an application which uses a form qer TeeTimesForComps to allow users
to reserve tee times.
when a record is deleted by a user the following code runs on the before
update event, and opens a second form frmtblPWLOG which determines if the
user is authorised to delete the record.

Private Sub Player_1_BeforeUpdate(Cancel As Integer)
Dim Response As String
Dim Oldvalue As String

If IsNull(Player_1.Oldvalue) Then
Player_1.Locked = False
Else
If Not IsNull(Player_1.Oldvalue) Then
Oldvalue = (Player_1.Oldvalue)
DoCmd.OpenForm "frmtblPWLOG", acNormal, "", "", acFormEdit, acWindowNormal, ""
Forms![frmtblPWLOG]![TeeTime] = Forms![qerTeeTimesForComps]![Tee Time]
Forms![frmtblPWLOG]![Player] = Oldvalue
Beep
Cancel = True
Player_1.Undo

Else
End If
End If
End Sub
This form works perfectly.
I have now used this form as a subform in another form for displaying
competition details.
When I now try to delete a record it opens form frmtblPWLOG, but hangs up at
the next line
Forms![frmtblPWLOG]![TeeTime] = Forms![qerTeeTimesForComps]![Tee Time]
with theerror
Cannot find the form frmTeeTimesFor Comps referred to in your expression.

Can anyone see any reason why it does not work as it does when used as a
stand alone form.
Thanks for any help
 
R

Rick Brandt

Dave Hawks wrote:
[snip]
This form works perfectly.
I have now used this form as a subform in another form for displaying
competition details.
When I now try to delete a record it opens form frmtblPWLOG, but
hangs up at the next line
Forms![frmtblPWLOG]![TeeTime] = Forms![qerTeeTimesForComps]![Tee Time]
with theerror
Cannot find the form frmTeeTimesFor Comps referred to in your
expression.

Can anyone see any reason why it does not work as it does when used
as a stand alone form.
Thanks for any help

A form displayed in a subform control is not considered an "open form" so it is
not found in the Forms collection. You have to reference it "via" the form iti
is embedded in and the subform control container where it is displayed...

Forms!ParentFormName!SubformControlName.Form![Tee Time]
 
G

Guest

Rick
Thanks For the help Problem solved.

--
Dave Hawks


Rick Brandt said:
Dave Hawks wrote:
[snip]
This form works perfectly.
I have now used this form as a subform in another form for displaying
competition details.
When I now try to delete a record it opens form frmtblPWLOG, but
hangs up at the next line
Forms![frmtblPWLOG]![TeeTime] = Forms![qerTeeTimesForComps]![Tee Time]
with theerror
Cannot find the form frmTeeTimesFor Comps referred to in your
expression.

Can anyone see any reason why it does not work as it does when used
as a stand alone form.
Thanks for any help

A form displayed in a subform control is not considered an "open form" so it is
not found in the Forms collection. You have to reference it "via" the form iti
is embedded in and the subform control container where it is displayed...

Forms!ParentFormName!SubformControlName.Form![Tee Time]
 

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