Linking form and subform problem (1 Viewer)

subbu

New member
Local time
Today, 06:28
Joined
Jun 5, 2002
Messages
7
I am a newbie and need some help.

I have a form A which opens a new form Form B on submitting a button.
The Form B has many buttons on it. Each one opes different form.

I want to move one of the button on form B to form A. and have the same functionality as it is having it on form B.

I have copied the button and the code for button B1 from form B to form A.
But I am getting and runtime error as-
XXX system can’t find the field ‘subfrm’ referred to in your expression

What is it that I might be missing.
How is Form B linked to Form C?

Please help

Here is the code that I copied from Form B to Form A --

Private Sub cmdB1_Click()
On Error GoTo Err1

Me!subfrm.SourceObject = "subfrmC"
Me!frmLabel.Caption = "C1"

Exit_cmdB1_Click:
Exit Sub

Err1:
MsgBox Err.Description
Resume Exit_cmdB1_Click
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:28
Joined
Aug 30, 2003
Messages
36,131
Answered on another site.
 

subbu

New member
Local time
Today, 06:28
Joined
Jun 5, 2002
Messages
7
Thanks Paul. I saw the reply on other site :)

I have posted new question there. If you could please answer it , that will really help.

Thanks a lot!
 

trucktime

Registered User.
Local time
Yesterday, 23:28
Joined
Oct 24, 2004
Messages
556
Button Problems

The problem is caused by the fact that now you moved the button to Form A the reference is incorrect. It is looking for a field on Form A while that field is actually on Form B, so it can't find it.

You may want to check the link below, there is a database called Subform Reference that demonstrates how to set focus on controls on subforms and subforms as well as retrieve values from subforms and subsubforms.
You can download it and check it out.

http://www.candace-tripp.com/_pages/access_downloads.asp

Here is some code that will help you in general on this subject
(with thanks to SJ McAbney, Moderator of this Forum)

Syntax for Main and Subforms

For the purpose of this FAQ, the following names are used:

* MainForm - replace with the name of the top level form
* SubformA - the name of the subform control on Mainform
* SubformB - the name of the subform control on the SubformA.



On the main form

To refer to a form property, such as RecordSource

* On Mainform
Code:

Me.RecordSource

* On SubformA
Code:

Me.SubformA.Form.RecordSource

* On SubformB
Code:

Me.SubformA.Form!SubformB.Form.RecordSource


To refer to a control

* On Mainform
Code:

Me.ControlName

* On SubformA
Code:

Me.SubformA.Form!ControlName

* On SubformB
Code:

Me.SubformA.Form!SubformB.Form!ControlName


To refer to a control property, such as Enabled

* On Mainform
Code:

Me.ControlName.Enabled

* On SubformA
Code:

Me.SubformA.Form!ControlName.Enabled

* On SubformB
Code:

Me.SubformA.Form!SubformB.Form!ControlName.Enabled


To refer to a subform control property, such as SourceObject

* On Mainform
Not applicable
* On SubformA
Code:

Me.SubformA.SourceObject

* On SubformB
Code:

Me.SubformA.Form!SubformB.SourceObject



On SubformA

To refer to a form property, such as RecordSource

* On Mainform
Code:

Me.Parent.RecordSource

* On SubformA
Code:

Me.RecordSource

* On SubformB
Code:

Me.SubformB.Form.RecordSource


To refer to a control

* On Mainform
Code:

Me.Parent!ControlName

* On SubformA
Code:

Me.ControlName

* On SubformB
Code:

Me.SubformB.Form!ControlName


To refer to a control property, such as Enabled

* On Mainform
Code:

Me.Parent!ControlName.Enabled

* On SubformA
Code:

Me.ControlName.Enabled

* On SubformB
Code:

Me.SubformB.Form!ControlName.Enabled


To refer to a subform control property, such as SourceObject

* On Mainform
Not applicable
* On SubformA
Not applicable
* On SubformB
Code:

Me.SubformB.SourceObject



On SubformB

To refer to a form property, such as RecordSource

* On Mainform
Code:

Me.Parent.Parent.RecordSource

* On SubformA
Code:

Me.Parent.RecordSource

* On SubformB
Code:

Me.RecordSource


To refer to a control

* On Mainform
Code:

Me.Parent.Parent!ControlName

* On SubformA
Code:

Me.Parent!ControlName

* On SubformB
Code:

Me.ControlName


To refer to a control property, such as Enabled

* On Mainform
Code:

Me.Parent.Parent.ControlName.Enabled

* On SubformA
Code:

Me.Parent.ControlName.Enabled

* On SubformB
Code:

Me.ControlName.Enabled


To refer to a subform control property, such as SourceObject

* On Mainform
Not applicable
* On SubformA
Not applicable
* On SubformB
Not applicable



Not on any of these forms

To refer to a form property, such as RecordSource

* On Mainform
Code:

Forms.Mainform.RecordSource

* On SubformA
Code:

Forms.Mainform!SubformA.Form.RecordSource

* On SubformB
Code:

Forms.Mainform!SubformA.Form!SubformB.
Form.RecordSource


To refer to a control

* On Mainform
Code:

Forms.Mainform!ControlName

* On SubformA
Code:

Forms.Mainform!SubformA.Form!ControlName

* On SubformB
Code:

Forms.Mainform!SubformA.Form!SubformB.
Form!ControlName


To refer to a control property, such as Enabled

* On Mainform
Code:

Forms.Mainform!ControlName.Enabled

* On SubformA
Code:

Forms.Mainform!SubformA.Form!ControlName.Enabled

* On SubformB
Code:

Forms.Mainform!SubformA.Form!SubformB.Form!ControlName.Enabled


To refer to a subform control property, such as SourceObject

* On Mainform
Not applicable
* On SubformA
Code:

Forms.Mainform!SubformA.SourceObject

* On SubformB
Code:

Forms.Mainform!SubformA.Form!SubformB.SourceObject
 

Users who are viewing this thread

Top Bottom