Calling a subform from another form

G

Guest

I've been trying for about a week now to figure out the code for this.
Here's what I'm doing - I have a form (frmSelectQuestions) with unbound combo
boxes filled in with values I entered. I want frmSelectQuestions to show
only records that correspond with the combo boxes. The info I want to filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both the form
and subform with just the one command button on frmSelectQuestions. I hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it refers
to "Who" which is a field on the subform. I know I need to bring the focus
to the subform, at least I think. So, it's the txtWho and cmbWho I'm having
trouble with as the txtWho is located on the subform frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & "'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
G

George Nicholson

Is frmToDoListGoalsDropDown the name of the *control* that contains the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure mine have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be open, so
trying to reference them by name will always fail.)

HTH,
 
G

Guest

Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question. Let me
try to example what I'm doing again. I have 3 forms total. One is a stand
alone (form1), the other two are a form with a subform (form2, subform1). I
want form1 to sort/filter records on both form2 and subform1 with the click
of one command button. Does that make sense? But when you say a subform is
never considered open, this says to me that it can't be called from any other
form but it's parent form, or itself. Am I understanding that correctly?

I appreciate all your help, this database is so complex, it sends records to
Outlook tasks, Word documents, and mass emails. But yet I can't figure this
little problem out, and it's so frustrating.
--
KC


George Nicholson said:
Is frmToDoListGoalsDropDown the name of the *control* that contains the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure mine have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be open, so
trying to reference them by name will always fail.)

HTH,

Wkatim said:
I've been trying for about a week now to figure out the code for this.
Here's what I'm doing - I have a form (frmSelectQuestions) with unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to show
only records that correspond with the combo boxes. The info I want to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both the form
and subform with just the one command button on frmSelectQuestions. I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & "'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
G

George Nicholson

But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt to
explain why you can't use the Forms collection to reference a subform. The
Forms collection, by definition, consists only of currently Open forms. *In
that context*, subforms are not considered to be an Open form because they
are not part of that collection.

HTH,

Wkatim said:
Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question. Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2, subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that correctly?

I appreciate all your help, this database is so complex, it sends records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


George Nicholson said:
Is frmToDoListGoalsDropDown the name of the *control* that contains the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be open,
so
trying to reference them by name will always fail.)

HTH,

Wkatim said:
I've been trying for about a week now to figure out the code for this.
Here's what I'm doing - I have a form (frmSelectQuestions) with unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both the
form
and subform with just the one command button on frmSelectQuestions. I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] &
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & "'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
G

Guest

I guess I used the wrong terminology. I do want to reference a subform when
the form that the subform control is on, is not open yet. I have used the
appropriate "drilldown", but still have not been able to get the code to work
for the subform.

I have 3 combo boxes on a form (comboform). When you select options on
these I want it to open the form (mainform) with the subform
control(subform), and filter it according to the choices made on the
(comboform). I can get the code to work to filter the mainform, but when I
try to reference the subform it tells me the field is not valid. Now, I
understand that a subform is a control on the form, but I guess I don't
understand why when I use the proper "drilldown" it's not working on the
subform.

I understand your answers, but it doesn't seem to be answering my questions,
unless I'm having a big huge brain f@rt.

Sorry to be such a pain. Hopefully I'll get my answers yet.
--
KC


George Nicholson said:
But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt to
explain why you can't use the Forms collection to reference a subform. The
Forms collection, by definition, consists only of currently Open forms. *In
that context*, subforms are not considered to be an Open form because they
are not part of that collection.

HTH,

Wkatim said:
Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question. Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2, subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that correctly?

I appreciate all your help, this database is so complex, it sends records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


George Nicholson said:
Is frmToDoListGoalsDropDown the name of the *control* that contains the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be open,
so
trying to reference them by name will always fail.)

HTH,

I've been trying for about a week now to figure out the code for this.
Here's what I'm doing - I have a form (frmSelectQuestions) with unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both the
form
and subform with just the one command button on frmSelectQuestions. I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] &
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & "'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
G

Guest

This is from my code, is it the proper "drilldown".

Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho

frmSelectDropDown is the main form
frmToDoListGoalsDropDown is the subform
txtWho is a control/text box on my subform.
--
KC


George Nicholson said:
But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt to
explain why you can't use the Forms collection to reference a subform. The
Forms collection, by definition, consists only of currently Open forms. *In
that context*, subforms are not considered to be an Open form because they
are not part of that collection.

HTH,

Wkatim said:
Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question. Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2, subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that correctly?

I appreciate all your help, this database is so complex, it sends records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


George Nicholson said:
Is frmToDoListGoalsDropDown the name of the *control* that contains the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be open,
so
trying to reference them by name will always fail.)

HTH,

I've been trying for about a week now to figure out the code for this.
Here's what I'm doing - I have a form (frmSelectQuestions) with unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both the
form
and subform with just the one command button on frmSelectQuestions. I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] &
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & "'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
D

Douglas J. Steele

Make sure that the name of the subform control on frmSelectDropDown is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the name of the
control may be something different. You have to use the name of the control,
not the name of the form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
This is from my code, is it the proper "drilldown".

Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho

frmSelectDropDown is the main form
frmToDoListGoalsDropDown is the subform
txtWho is a control/text box on my subform.
--
KC


George Nicholson said:
But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you
just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt
to
explain why you can't use the Forms collection to reference a subform.
The
Forms collection, by definition, consists only of currently Open forms.
*In
that context*, subforms are not considered to be an Open form because
they
are not part of that collection.

HTH,

Wkatim said:
Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question.
Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2,
subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a
subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

I appreciate all your help, this database is so complex, it sends
records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


:

Is frmToDoListGoalsDropDown the name of the *control* that contains
the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of
the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure
mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be
open,
so
trying to reference them by name will always fail.)

HTH,

I've been trying for about a week now to figure out the code for
this.
Here's what I'm doing - I have a form (frmSelectQuestions) with
unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want
to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both
the
form
and subform with just the one command button on frmSelectQuestions.
I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring
the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho
I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority]
&
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" &
"'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
G

Guest

I assume you do that in the properties, and it is the "Name" of the control.
The name is the same as the record source, and I've been told to change the
name to save on confusion. Is this where I would find the name of the
control?
--
KC


Douglas J. Steele said:
Make sure that the name of the subform control on frmSelectDropDown is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the name of the
control may be something different. You have to use the name of the control,
not the name of the form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
This is from my code, is it the proper "drilldown".

Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho

frmSelectDropDown is the main form
frmToDoListGoalsDropDown is the subform
txtWho is a control/text box on my subform.
--
KC


George Nicholson said:
But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you
just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt
to
explain why you can't use the Forms collection to reference a subform.
The
Forms collection, by definition, consists only of currently Open forms.
*In
that context*, subforms are not considered to be an Open form because
they
are not part of that collection.

HTH,

Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question.
Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2,
subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a
subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

I appreciate all your help, this database is so complex, it sends
records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


:

Is frmToDoListGoalsDropDown the name of the *control* that contains
the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of
the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure
mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be
open,
so
trying to reference them by name will always fail.)

HTH,

I've been trying for about a week now to figure out the code for
this.
Here's what I'm doing - I have a form (frmSelectQuestions) with
unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want
to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both
the
form
and subform with just the one command button on frmSelectQuestions.
I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring
the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho
I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority]
&
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" &
"'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
G

Guest

And if it is where I'm to find it, and it is the name of the control, why the
heck isn't my code working! I appreciate your time and patience with me.
--
KC


Wkatim said:
I assume you do that in the properties, and it is the "Name" of the control.
The name is the same as the record source, and I've been told to change the
name to save on confusion. Is this where I would find the name of the
control?
--
KC


Douglas J. Steele said:
Make sure that the name of the subform control on frmSelectDropDown is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the name of the
control may be something different. You have to use the name of the control,
not the name of the form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
This is from my code, is it the proper "drilldown".

Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho

frmSelectDropDown is the main form
frmToDoListGoalsDropDown is the subform
txtWho is a control/text box on my subform.
--
KC


:

But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you
just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt
to
explain why you can't use the Forms collection to reference a subform.
The
Forms collection, by definition, consists only of currently Open forms.
*In
that context*, subforms are not considered to be an Open form because
they
are not part of that collection.

HTH,

Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question.
Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2,
subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a
subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

I appreciate all your help, this database is so complex, it sends
records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


:

Is frmToDoListGoalsDropDown the name of the *control* that contains
the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of
the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure
mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be
open,
so
trying to reference them by name will always fail.)

HTH,

I've been trying for about a week now to figure out the code for
this.
Here's what I'm doing - I have a form (frmSelectQuestions) with
unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want
to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both
the
form
and subform with just the one command button on frmSelectQuestions.
I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring
the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho
I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority]
&
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" &
"'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
D

Douglas J. Steele

What's the complete context in which you're using the reference (and what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'" & _
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't compare a
value from a subform to a value on the form. The Criteria needs to be a
Where statement (without the keyword Where). What you've got ends up being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are incorrect)
 
G

Guest

Please don't think I'm a hopeless cause. But I'm not completely
understanding your question/answer. What do you mean by the "comple
context"? My code? Or what am I trying to do?

Thanks, Kathy
--
KC


Douglas J. Steele said:
What's the complete context in which you're using the reference (and what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'" & _
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't compare a
value from a subform to a value on the form. The Criteria needs to be a
Where statement (without the keyword Where). What you've got ends up being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are incorrect)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
G

George Nicholson

I do want to reference a subform when the form that the subform control is
on, is not open yet.

If the form containing the subform is not open, you can't reference the
subform because you can't reference the parent.

The parent *has* to be open. Period.

HTH,

Wkatim said:
I guess I used the wrong terminology. I do want to reference a subform
when
the form that the subform control is on, is not open yet. I have used the
appropriate "drilldown", but still have not been able to get the code to
work
for the subform.

I have 3 combo boxes on a form (comboform). When you select options on
these I want it to open the form (mainform) with the subform
control(subform), and filter it according to the choices made on the
(comboform). I can get the code to work to filter the mainform, but when
I
try to reference the subform it tells me the field is not valid. Now, I
understand that a subform is a control on the form, but I guess I don't
understand why when I use the proper "drilldown" it's not working on the
subform.

I understand your answers, but it doesn't seem to be answering my
questions,
unless I'm having a big huge brain f@rt.

Sorry to be such a pain. Hopefully I'll get my answers yet.
--
KC


George Nicholson said:
But when you say a subform is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

Called or referenced?

A current subform can certainly be referenced from any open form, you
just
have to use the necessary drilldown:
Forms("someOpenForm").NameOfContainerControl.Form...

When I said that a subform is never considered open, that was an attempt
to
explain why you can't use the Forms collection to reference a subform.
The
Forms collection, by definition, consists only of currently Open forms.
*In
that context*, subforms are not considered to be an Open form because
they
are not part of that collection.

HTH,

Wkatim said:
Thanks for the response.

frmToDoListGoalsDropDown is the name of the control, and I had already
used
the link you sent, but thanks.

Now for the nitty gritty. Your FYI, may have answered my question.
Let
me
try to example what I'm doing again. I have 3 forms total. One is a
stand
alone (form1), the other two are a form with a subform (form2,
subform1).
I
want form1 to sort/filter records on both form2 and subform1 with the
click
of one command button. Does that make sense? But when you say a
subform
is
never considered open, this says to me that it can't be called from any
other
form but it's parent form, or itself. Am I understanding that
correctly?

I appreciate all your help, this database is so complex, it sends
records
to
Outlook tasks, Word documents, and mass emails. But yet I can't figure
this
little problem out, and it's so frustrating.
--
KC


:

Is frmToDoListGoalsDropDown the name of the *control* that contains
the
subform? For your code to work, it has to be.

You can't reference a subform by the form name, only by the name of
the
control that contains the subform. *Sometimes* a "helpful" wizard or
drag&drop will give the control the same name as the subform, but its
impossible to tell if that's true in your case. I always make sure
mine
have
independent names to avoid confusion.

http://mvps.org/access/forms/frm0031.htm
How to: Refer to Form and Subform properties and controls

(FYI: to be part of the Forms collection [Forms!MyForm or
Forms("myForm")],
a Form has to be "open". Subforms are simply not considered to be
open,
so
trying to reference them by name will always fail.)

HTH,

I've been trying for about a week now to figure out the code for
this.
Here's what I'm doing - I have a form (frmSelectQuestions) with
unbound
combo
boxes filled in with values I entered. I want frmSelectQuestions to
show
only records that correspond with the combo boxes. The info I want
to
filter
is on a form (frmSelectDropDown) that contains a subform
(frmToDoListGoalsDropDown). I want to filter by controls on both
the
form
and subform with just the one command button on frmSelectQuestions.
I
hope
this makes sense.

Here is my code. I keep getting that it can't find my field when it
refers
to "Who" which is a field on the subform. I know I need to bring
the
focus
to the subform, at least I think. So, it's the txtWho and cmbWho
I'm
having
trouble with as the txtWho is located on the subform
frmToDoListGoalsDropDown.

PLEASE HELP ME!!!!!!!!!!


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSelectDropDown"


stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority]
&
"'"
And "[Where]=" & "'" & Me![cmbWhere] & "'" And
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" &
"'" &
Forms!frmSelectQuestions.cmbWho & "'"


DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameDone, acSaveNo



Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click



End Sub
 
D

Douglas J. Steele

Both. I want to see the relevant code, as well as know what you're trying to
do.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
Please don't think I'm a hopeless cause. But I'm not completely
understanding your question/answer. What do you mean by the "comple
context"? My code? Or what am I trying to do?

Thanks, Kathy
--
KC


Douglas J. Steele said:
What's the complete context in which you're using the reference (and what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'" &
_
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't compare
a
value from a subform to a value on the form. The Criteria needs to be a
Where statement (without the keyword Where). What you've got ends up
being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are
incorrect)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
And if it is where I'm to find it, and it is the name of the control,
why
the
heck isn't my code working! I appreciate your time and patience with
me.
--
KC


:

I assume you do that in the properties, and it is the "Name" of the
control.
The name is the same as the record source, and I've been told to
change
the
name to save on confusion. Is this where I would find the name of the
control?
--
KC


:

Make sure that the name of the subform control on frmSelectDropDown
is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the
name
of the
control may be something different. You have to use the name of the
control,
not the name of the form being used as a subform.
 
G

Guest

Here's the skinny on it. I have a form (frmSelectQuestions), it has 3
unbound combo boxes (cmbPriority, cmbWhere, and cmbWho) and a command button.
When choices are made in the combo boxes and the command button is pushed I
want this form to open the form (frmSelectDropDown this has the subform,
frmToDoListGoalsDropDown) and show only the records that have the values
chosen in the combo boxes. I can get the code to work when it references the
parent form (frmSelectDropDown), but when I reference the subform
(frmToDoListGoalsDropDown) it tells me there is no field named,
frmToDoListGoalsDropDown. Now this tells me I'm not referencing it
correctly. The controls I want to reference on the parent form and the
subform are as follows (Maingoals.priority) on the frmSelectDropDown
(txtWhere) on the frmSelectDropDown
(txtWho) on the subform frmToDoListGoalsDropDown

Now the following code works for the priority and the where, but when I add
this piece of code it tells me that the field isn't there, as I stated
earlier.


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stDocNameQuest As String

stDocName = "frmSelectDropDown"
stDocNameQuest = "frmSelectQuestions"

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'
And [txtWhere]=" & "'" & Me![cmbWhere] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameQuest, acSaveNo


Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click


And here is the piece of problem code, which you had already looked at.


"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho="
Forms!frmSelectQuestions.cmbWho & "'"


You said it was fundamentally incorrect, which could be my problem, of
course. I hope that explained it well enough, if not let me know and I'll
give it another shot.

Thanks for your patience and help.

--
KC


Douglas J. Steele said:
Both. I want to see the relevant code, as well as know what you're trying to
do.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
Please don't think I'm a hopeless cause. But I'm not completely
understanding your question/answer. What do you mean by the "comple
context"? My code? Or what am I trying to do?

Thanks, Kathy
--
KC


Douglas J. Steele said:
What's the complete context in which you're using the reference (and what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'" &
_
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't compare
a
value from a subform to a value on the form. The Criteria needs to be a
Where statement (without the keyword Where). What you've got ends up
being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are
incorrect)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


And if it is where I'm to find it, and it is the name of the control,
why
the
heck isn't my code working! I appreciate your time and patience with
me.
--
KC


:

I assume you do that in the properties, and it is the "Name" of the
control.
The name is the same as the record source, and I've been told to
change
the
name to save on confusion. Is this where I would find the name of the
control?
--
KC


:

Make sure that the name of the subform control on frmSelectDropDown
is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the
name
of the
control may be something different. You have to use the name of the
control,
not the name of the form being used as a subform.
 
D

Douglas J. Steele

You shouldn't need to reference the subform in your criteria to open the
parent form.

What gets displayed on the subform is determined from the LinkMasterFields
and LinkChildFields properties of the subform control on the parent form.
You definitely cannot refer to a control on the subform when the parent form
isn't open yet.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Wkatim said:
Here's the skinny on it. I have a form (frmSelectQuestions), it has 3
unbound combo boxes (cmbPriority, cmbWhere, and cmbWho) and a command
button.
When choices are made in the combo boxes and the command button is pushed
I
want this form to open the form (frmSelectDropDown this has the subform,
frmToDoListGoalsDropDown) and show only the records that have the values
chosen in the combo boxes. I can get the code to work when it references
the
parent form (frmSelectDropDown), but when I reference the subform
(frmToDoListGoalsDropDown) it tells me there is no field named,
frmToDoListGoalsDropDown. Now this tells me I'm not referencing it
correctly. The controls I want to reference on the parent form and the
subform are as follows (Maingoals.priority) on the frmSelectDropDown
(txtWhere) on the frmSelectDropDown
(txtWho) on the subform frmToDoListGoalsDropDown

Now the following code works for the priority and the where, but when I
add
this piece of code it tells me that the field isn't there, as I stated
earlier.


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stDocNameQuest As String

stDocName = "frmSelectDropDown"
stDocNameQuest = "frmSelectQuestions"

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'
And [txtWhere]=" & "'" & Me![cmbWhere] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameQuest, acSaveNo


Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click


And here is the piece of problem code, which you had already looked at.


"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho="
Forms!frmSelectQuestions.cmbWho & "'"


You said it was fundamentally incorrect, which could be my problem, of
course. I hope that explained it well enough, if not let me know and I'll
give it another shot.

Thanks for your patience and help.

--
KC


Douglas J. Steele said:
Both. I want to see the relevant code, as well as know what you're trying
to
do.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wkatim said:
Please don't think I'm a hopeless cause. But I'm not completely
understanding your question/answer. What do you mean by the "comple
context"? My code? Or what am I trying to do?

Thanks, Kathy
--
KC


:

What's the complete context in which you're using the reference (and
what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] &
"'" &
_
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't
compare
a
value from a subform to a value on the form. The Criteria needs to be
a
Where statement (without the keyword Where). What you've got ends up
being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are
incorrect)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


And if it is where I'm to find it, and it is the name of the
control,
why
the
heck isn't my code working! I appreciate your time and patience
with
me.
--
KC


:

I assume you do that in the properties, and it is the "Name" of the
control.
The name is the same as the record source, and I've been told to
change
the
name to save on confusion. Is this where I would find the name of
the
control?
--
KC


:

Make sure that the name of the subform control on
frmSelectDropDown
is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the
name
of the
control may be something different. You have to use the name of
the
control,
not the name of the form being used as a subform.
 
G

Guest

Unfortunately that answers my question. I did work around the issue by using
a Tabbed control, but I still wanted to know if I was doing something wrong.

Thanks to both of you for your time, patience, and knowledge.

P.S. - let me know if Access ever changes that subform control rule. :)
--
KC


Douglas J. Steele said:
You shouldn't need to reference the subform in your criteria to open the
parent form.

What gets displayed on the subform is determined from the LinkMasterFields
and LinkChildFields properties of the subform control on the parent form.
You definitely cannot refer to a control on the subform when the parent form
isn't open yet.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Wkatim said:
Here's the skinny on it. I have a form (frmSelectQuestions), it has 3
unbound combo boxes (cmbPriority, cmbWhere, and cmbWho) and a command
button.
When choices are made in the combo boxes and the command button is pushed
I
want this form to open the form (frmSelectDropDown this has the subform,
frmToDoListGoalsDropDown) and show only the records that have the values
chosen in the combo boxes. I can get the code to work when it references
the
parent form (frmSelectDropDown), but when I reference the subform
(frmToDoListGoalsDropDown) it tells me there is no field named,
frmToDoListGoalsDropDown. Now this tells me I'm not referencing it
correctly. The controls I want to reference on the parent form and the
subform are as follows (Maingoals.priority) on the frmSelectDropDown
(txtWhere) on the frmSelectDropDown
(txtWho) on the subform frmToDoListGoalsDropDown

Now the following code works for the priority and the where, but when I
add
this piece of code it tells me that the field isn't there, as I stated
earlier.


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stDocNameQuest As String

stDocName = "frmSelectDropDown"
stDocNameQuest = "frmSelectQuestions"

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'
And [txtWhere]=" & "'" & Me![cmbWhere] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameQuest, acSaveNo


Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click


And here is the piece of problem code, which you had already looked at.


"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho="
Forms!frmSelectQuestions.cmbWho & "'"


You said it was fundamentally incorrect, which could be my problem, of
course. I hope that explained it well enough, if not let me know and I'll
give it another shot.

Thanks for your patience and help.

--
KC


Douglas J. Steele said:
Both. I want to see the relevant code, as well as know what you're trying
to
do.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Please don't think I'm a hopeless cause. But I'm not completely
understanding your question/answer. What do you mean by the "comple
context"? My code? Or what am I trying to do?

Thanks, Kathy
--
KC


:

What's the complete context in which you're using the reference (and
what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] &
"'" &
_
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't
compare
a
value from a subform to a value on the form. The Criteria needs to be
a
Where statement (without the keyword Where). What you've got ends up
being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are
incorrect)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


And if it is where I'm to find it, and it is the name of the
control,
why
the
heck isn't my code working! I appreciate your time and patience
with
me.
--
KC


:

I assume you do that in the properties, and it is the "Name" of the
control.
The name is the same as the record source, and I've been told to
change
the
name to save on confusion. Is this where I would find the name of
the
control?
--
KC


:

Make sure that the name of the subform control on
frmSelectDropDown
is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the
name
of the
control may be something different. You have to use the name of
the
control,
not the name of the form being used as a subform.
 
G

Guest

Oh, and I do know about the link between the form and subform, and this was
already there. And my subform was already "filtered" based on this. I
wanted to narrow it down even more with another field. And I knew I didn't
need to reference my subform, I was just trying to do something that wasn't
possible. I just wanted to let you know I'm not a totally stupid girl. ;)
--
KC


Douglas J. Steele said:
You shouldn't need to reference the subform in your criteria to open the
parent form.

What gets displayed on the subform is determined from the LinkMasterFields
and LinkChildFields properties of the subform control on the parent form.
You definitely cannot refer to a control on the subform when the parent form
isn't open yet.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Wkatim said:
Here's the skinny on it. I have a form (frmSelectQuestions), it has 3
unbound combo boxes (cmbPriority, cmbWhere, and cmbWho) and a command
button.
When choices are made in the combo boxes and the command button is pushed
I
want this form to open the form (frmSelectDropDown this has the subform,
frmToDoListGoalsDropDown) and show only the records that have the values
chosen in the combo boxes. I can get the code to work when it references
the
parent form (frmSelectDropDown), but when I reference the subform
(frmToDoListGoalsDropDown) it tells me there is no field named,
frmToDoListGoalsDropDown. Now this tells me I'm not referencing it
correctly. The controls I want to reference on the parent form and the
subform are as follows (Maingoals.priority) on the frmSelectDropDown
(txtWhere) on the frmSelectDropDown
(txtWho) on the subform frmToDoListGoalsDropDown

Now the following code works for the priority and the where, but when I
add
this piece of code it tells me that the field isn't there, as I stated
earlier.


Private Sub cmdPriority_Click()
On Error GoTo Err_cmdPriority_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stDocNameQuest As String

stDocName = "frmSelectDropDown"
stDocNameQuest = "frmSelectQuestions"

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] & "'
And [txtWhere]=" & "'" & Me![cmbWhere] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stDocNameQuest, acSaveNo


Exit_cmdPriority_Click:
Exit Sub

Err_cmdPriority_Click:
MsgBox Err.Description
Resume Exit_cmdPriority_Click


And here is the piece of problem code, which you had already looked at.


"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho="
Forms!frmSelectQuestions.cmbWho & "'"


You said it was fundamentally incorrect, which could be my problem, of
course. I hope that explained it well enough, if not let me know and I'll
give it another shot.

Thanks for your patience and help.

--
KC


Douglas J. Steele said:
Both. I want to see the relevant code, as well as know what you're trying
to
do.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Please don't think I'm a hopeless cause. But I'm not completely
understanding your question/answer. What do you mean by the "comple
context"? My code? Or what am I trying to do?

Thanks, Kathy
--
KC


:

What's the complete context in which you're using the reference (and
what
does not working mean in this case)?

Looking at your original post, you have something like:

stLinkCriteria = "[MainGoals.Priority]=" & "'" & Me![cmbPriority] &
"'" &
_
And "[Where]=" & "'" & Me![cmbWhere] & "'" And & _
"Forms!frmSelectDropDown!frmToDoListGoalsDropDown.Form!txtWho=" & _
Forms!frmSelectQuestions.cmbWho & "'"

which is fundamentally incorrect. Criteria for open a form can't
compare
a
value from a subform to a value on the form. The Criteria needs to be
a
Where statement (without the keyword Where). What you've got ends up
being
something like

[MainGoals.Priority]= 'High' And [Where]='Redmond' And 'Bill' = 'Bill'

(Not only that, but even if that were possible, your quotes are
incorrect)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


And if it is where I'm to find it, and it is the name of the
control,
why
the
heck isn't my code working! I appreciate your time and patience
with
me.
--
KC


:

I assume you do that in the properties, and it is the "Name" of the
control.
The name is the same as the record source, and I've been told to
change
the
name to save on confusion. Is this where I would find the name of
the
control?
--
KC


:

Make sure that the name of the subform control on
frmSelectDropDown
is
frmToDoListGoalsDropDown. Depending on how you added
frmToDoListGoalsDropDown as a subform on frmSelectDropDown, the
name
of the
control may be something different. You have to use the name of
the
control,
not the name of the form being used as a subform.
 

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