Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Connecting commands on form

Geek News

Connecting commands on form
Evan 12/19/2008 10:43:03 PM
I've created a form with a drop-down list, command button and subform and
would like to connect the three together. So that when name1 is selected
from the dropdown list and a command button "Go" is clicked name1's subform
opens as the subform in the form or if name2 is selected and the "go" button
is clicked then name2's subform will appear as the subform. Is this
possible? Can anyone help? I'm assuming that I need to use the
DoCmd:OpenSubForm and then use an If ElseIf Statement.
Re: Connecting commands on form
"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> 12/20/2008 3:50:23 AM
Evan it is even easier than that. When you select a name from an unbound
combobox, you can have the form move to that record, and the subform will as
well.

Two things that make it very easy. When you add the dropdown list, use 2
columns, the ID (primary key) column, and the Name. If you have wizards
enabled (the magic wand in the toolbox) a dialog will come up to walk you
through the process.

Second, when you add a subform control, from the toolbox, a wizard will walk
you through the process and automatically link the form and subform.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
[Quoted Text]
> I've created a form with a drop-down list, command button and subform and
> would like to connect the three together. So that when name1 is selected
> from the dropdown list and a command button "Go" is clicked name1's
> subform
> opens as the subform in the form or if name2 is selected and the "go"
> button
> is clicked then name2's subform will appear as the subform. Is this
> possible? Can anyone help? I'm assuming that I need to use the
> DoCmd:OpenSubForm and then use an If ElseIf Statement.


Re: Connecting commands on form
Evan 12/20/2008 4:01:01 PM
I wish this were so easy. I've created a form with a combo box of names
linked to a table of names & NameID's (primary key). I've also created the
command button: "Go" using: Form Operations > Open form > specific form >
open form/show all records. The specific form opens as a separate form. I
need the form named in the combo box to open as a subform in the form. How
do I do that?

"Arvin Meyer [MVP]" wrote:

[Quoted Text]
> Evan it is even easier than that. When you select a name from an unbound
> combobox, you can have the form move to that record, and the subform will as
> well.
>
> Two things that make it very easy. When you add the dropdown list, use 2
> columns, the ID (primary key) column, and the Name. If you have wizards
> enabled (the magic wand in the toolbox) a dialog will come up to walk you
> through the process.
>
> Second, when you add a subform control, from the toolbox, a wizard will walk
> you through the process and automatically link the form and subform.
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
> > I've created a form with a drop-down list, command button and subform and
> > would like to connect the three together. So that when name1 is selected
> > from the dropdown list and a command button "Go" is clicked name1's
> > subform
> > opens as the subform in the form or if name2 is selected and the "go"
> > button
> > is clicked then name2's subform will appear as the subform. Is this
> > possible? Can anyone help? I'm assuming that I need to use the
> > DoCmd:OpenSubForm and then use an If ElseIf Statement.
>
>
>
Re: Connecting commands on form
Evan 12/20/2008 8:56:04 PM
I wrote code so that when a name in a combo box is clicked on its
corrosponding form opens but as a separate window. Is it possible to get the
form to open as a subform of the form on which the combo box is located?

"Evan" wrote:

[Quoted Text]
> I wish this were so easy. I've created a form with a combo box of names
> linked to a table of names & NameID's (primary key). I've also created the
> command button: "Go" using: Form Operations > Open form > specific form >
> open form/show all records. The specific form opens as a separate form. I
> need the form named in the combo box to open as a subform in the form. How
> do I do that?
>
> "Arvin Meyer [MVP]" wrote:
>
> > Evan it is even easier than that. When you select a name from an unbound
> > combobox, you can have the form move to that record, and the subform will as
> > well.
> >
> > Two things that make it very easy. When you add the dropdown list, use 2
> > columns, the ID (primary key) column, and the Name. If you have wizards
> > enabled (the magic wand in the toolbox) a dialog will come up to walk you
> > through the process.
> >
> > Second, when you add a subform control, from the toolbox, a wizard will walk
> > you through the process and automatically link the form and subform.
> > --
> > Arvin Meyer, MCP, MVP
> > http://www.datastrat.com
> > http://www.mvps.org/access
> > http://www.accessmvp.com
> >
> >
> > "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> > news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
> > > I've created a form with a drop-down list, command button and subform and
> > > would like to connect the three together. So that when name1 is selected
> > > from the dropdown list and a command button "Go" is clicked name1's
> > > subform
> > > opens as the subform in the form or if name2 is selected and the "go"
> > > button
> > > is clicked then name2's subform will appear as the subform. Is this
> > > possible? Can anyone help? I'm assuming that I need to use the
> > > DoCmd:OpenSubForm and then use an If ElseIf Statement.
> >
> >
> >
Re: Connecting commands on form
"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> 12/21/2008 4:19:01 AM
By changing the Source Object property of the subform control. But it still
needs to be linked to the main form, or the recordsource has to use the
combobox as a criteria:

Sub cboNameID_AfterUpdate()
Me.NameOfSubformControl.SourceObject = "SubFormName"
Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever
Where NameID =" & Me.cboNameID
End Sub

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
news:34E6AC4C-FFA0-4064-AE74-909F762876F2[ at ]microsoft.com...
[Quoted Text]
>I wrote code so that when a name in a combo box is clicked on its
> corrosponding form opens but as a separate window. Is it possible to get
> the
> form to open as a subform of the form on which the combo box is located?
>
> "Evan" wrote:
>
>> I wish this were so easy. I've created a form with a combo box of names
>> linked to a table of names & NameID's (primary key). I've also created
>> the
>> command button: "Go" using: Form Operations > Open form > specific form
>> >
>> open form/show all records. The specific form opens as a separate form.
>> I
>> need the form named in the combo box to open as a subform in the form.
>> How
>> do I do that?
>>
>> "Arvin Meyer [MVP]" wrote:
>>
>> > Evan it is even easier than that. When you select a name from an
>> > unbound
>> > combobox, you can have the form move to that record, and the subform
>> > will as
>> > well.
>> >
>> > Two things that make it very easy. When you add the dropdown list, use
>> > 2
>> > columns, the ID (primary key) column, and the Name. If you have wizards
>> > enabled (the magic wand in the toolbox) a dialog will come up to walk
>> > you
>> > through the process.
>> >
>> > Second, when you add a subform control, from the toolbox, a wizard will
>> > walk
>> > you through the process and automatically link the form and subform.
>> > --
>> > Arvin Meyer, MCP, MVP
>> > http://www.datastrat.com
>> > http://www.mvps.org/access
>> > http://www.accessmvp.com
>> >
>> >
>> > "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
>> > news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
>> > > I've created a form with a drop-down list, command button and subform
>> > > and
>> > > would like to connect the three together. So that when name1 is
>> > > selected
>> > > from the dropdown list and a command button "Go" is clicked name1's
>> > > subform
>> > > opens as the subform in the form or if name2 is selected and the "go"
>> > > button
>> > > is clicked then name2's subform will appear as the subform. Is this
>> > > possible? Can anyone help? I'm assuming that I need to use the
>> > > DoCmd:OpenSubForm and then use an If ElseIf Statement.
>> >
>> >
>> >


Re: Connecting commands on form
Evan 12/23/2008 4:43:00 AM
I need a bit more help. When I click on a name in the comboBox I get "sub or
function not defined." Is the record set code used for the main form
causing a problem? Also wasn't sure what tbl Whatever referred to? I've
substituted the names of the cbo, subformControl, and NameID and put the
following code in the Module: Combobox AfterUpdate:

Private Sub Combo7_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[CountryID] = " & Str(Nz(Me![Combo7], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Me.BRSch.SourceObject = "SubFormName"
Me.BRSch.Form.RecordSource = "Select * From tblWhatever"
Where NameID = " & Me.BRSch"

End Sub

When I click on a name in the comboBox I get "sub or function not defined."
Is the record set code used for the main form causing a problem? Also
wasn't sure what tbl Whatever referred to?

"Arvin Meyer [MVP]" wrote:

[Quoted Text]
> By changing the Source Object property of the subform control. But it still
> needs to be linked to the main form, or the recordsource has to use the
> combobox as a criteria:
>
> Sub cboNameID_AfterUpdate()
> Me.NameOfSubformControl.SourceObject = "SubFormName"
> Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever
> Where NameID =" & Me.cboNameID
> End Sub
>
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> news:34E6AC4C-FFA0-4064-AE74-909F762876F2[ at ]microsoft.com...
> >I wrote code so that when a name in a combo box is clicked on its
> > corrosponding form opens but as a separate window. Is it possible to get
> > the
> > form to open as a subform of the form on which the combo box is located?
> >
> > "Evan" wrote:
> >
> >> I wish this were so easy. I've created a form with a combo box of names
> >> linked to a table of names & NameID's (primary key). I've also created
> >> the
> >> command button: "Go" using: Form Operations > Open form > specific form
> >> >
> >> open form/show all records. The specific form opens as a separate form.
> >> I
> >> need the form named in the combo box to open as a subform in the form.
> >> How
> >> do I do that?
> >>
> >> "Arvin Meyer [MVP]" wrote:
> >>
> >> > Evan it is even easier than that. When you select a name from an
> >> > unbound
> >> > combobox, you can have the form move to that record, and the subform
> >> > will as
> >> > well.
> >> >
> >> > Two things that make it very easy. When you add the dropdown list, use
> >> > 2
> >> > columns, the ID (primary key) column, and the Name. If you have wizards
> >> > enabled (the magic wand in the toolbox) a dialog will come up to walk
> >> > you
> >> > through the process.
> >> >
> >> > Second, when you add a subform control, from the toolbox, a wizard will
> >> > walk
> >> > you through the process and automatically link the form and subform.
> >> > --
> >> > Arvin Meyer, MCP, MVP
> >> > http://www.datastrat.com
> >> > http://www.mvps.org/access
> >> > http://www.accessmvp.com
> >> >
> >> >
> >> > "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> >> > news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
> >> > > I've created a form with a drop-down list, command button and subform
> >> > > and
> >> > > would like to connect the three together. So that when name1 is
> >> > > selected
> >> > > from the dropdown list and a command button "Go" is clicked name1's
> >> > > subform
> >> > > opens as the subform in the form or if name2 is selected and the "go"
> >> > > button
> >> > > is clicked then name2's subform will appear as the subform. Is this
> >> > > possible? Can anyone help? I'm assuming that I need to use the
> >> > > DoCmd:OpenSubForm and then use an If ElseIf Statement.
> >> >
> >> >
> >> >
>
>
>
Re: Connecting commands on form
"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> 12/25/2008 4:02:03 AM
You may not have a reference to DAO. Open any code window and uncheck the
reference to ActiveX Data Objects (ADO) and check the one marked:

Microsoft DAO 3.6 Object Library

If that still doesn't help, set a breakpoint at:

Set rs = Me.Recordset.Clone

and step through the code (F8) to find the error.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
news:94FBD955-09CB-4C7E-92A3-B3C88B9BE801[ at ]microsoft.com...
[Quoted Text]
>I need a bit more help. When I click on a name in the comboBox I get "sub
>or
> function not defined." Is the record set code used for the main form
> causing a problem? Also wasn't sure what tbl Whatever referred to? I've
> substituted the names of the cbo, subformControl, and NameID and put the
> following code in the Module: Combobox AfterUpdate:
>
> Private Sub Combo7_AfterUpdate()
> ' Find the record that matches the control.
> Dim rs As Object
>
> Set rs = Me.Recordset.Clone
> rs.FindFirst "[CountryID] = " & Str(Nz(Me![Combo7], 0))
> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
>
> Me.BRSch.SourceObject = "SubFormName"
> Me.BRSch.Form.RecordSource = "Select * From tblWhatever"
> Where NameID = " & Me.BRSch"
>
> End Sub
>
> When I click on a name in the comboBox I get "sub or function not
> defined."
> Is the record set code used for the main form causing a problem? Also
> wasn't sure what tbl Whatever referred to?
>
> "Arvin Meyer [MVP]" wrote:
>
>> By changing the Source Object property of the subform control. But it
>> still
>> needs to be linked to the main form, or the recordsource has to use the
>> combobox as a criteria:
>>
>> Sub cboNameID_AfterUpdate()
>> Me.NameOfSubformControl.SourceObject = "SubFormName"
>> Me.NameOfSubformControl.Form.RecordSource = "Select * From
>> tblWhatever
>> Where NameID =" & Me.cboNameID
>> End Sub
>>
>> --
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.mvps.org/access
>> http://www.accessmvp.com
>>
>>
>> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
>> news:34E6AC4C-FFA0-4064-AE74-909F762876F2[ at ]microsoft.com...
>> >I wrote code so that when a name in a combo box is clicked on its
>> > corrosponding form opens but as a separate window. Is it possible to
>> > get
>> > the
>> > form to open as a subform of the form on which the combo box is
>> > located?
>> >
>> > "Evan" wrote:
>> >
>> >> I wish this were so easy. I've created a form with a combo box of
>> >> names
>> >> linked to a table of names & NameID's (primary key). I've also
>> >> created
>> >> the
>> >> command button: "Go" using: Form Operations > Open form > specific
>> >> form
>> >> >
>> >> open form/show all records. The specific form opens as a separate
>> >> form.
>> >> I
>> >> need the form named in the combo box to open as a subform in the form.
>> >> How
>> >> do I do that?
>> >>
>> >> "Arvin Meyer [MVP]" wrote:
>> >>
>> >> > Evan it is even easier than that. When you select a name from an
>> >> > unbound
>> >> > combobox, you can have the form move to that record, and the subform
>> >> > will as
>> >> > well.
>> >> >
>> >> > Two things that make it very easy. When you add the dropdown list,
>> >> > use
>> >> > 2
>> >> > columns, the ID (primary key) column, and the Name. If you have
>> >> > wizards
>> >> > enabled (the magic wand in the toolbox) a dialog will come up to
>> >> > walk
>> >> > you
>> >> > through the process.
>> >> >
>> >> > Second, when you add a subform control, from the toolbox, a wizard
>> >> > will
>> >> > walk
>> >> > you through the process and automatically link the form and subform.
>> >> > --
>> >> > Arvin Meyer, MCP, MVP
>> >> > http://www.datastrat.com
>> >> > http://www.mvps.org/access
>> >> > http://www.accessmvp.com
>> >> >
>> >> >
>> >> > "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
>> >> > news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
>> >> > > I've created a form with a drop-down list, command button and
>> >> > > subform
>> >> > > and
>> >> > > would like to connect the three together. So that when name1 is
>> >> > > selected
>> >> > > from the dropdown list and a command button "Go" is clicked
>> >> > > name1's
>> >> > > subform
>> >> > > opens as the subform in the form or if name2 is selected and the
>> >> > > "go"
>> >> > > button
>> >> > > is clicked then name2's subform will appear as the subform. Is
>> >> > > this
>> >> > > possible? Can anyone help? I'm assuming that I need to use the
>> >> > > DoCmd:OpenSubForm and then use an If ElseIf Statement.
>> >> >
>> >> >
>> >> >
>>
>>
>>


Re: Connecting commands on form
Evan 12/30/2008 3:53:00 AM
The error occurs at the "Where NameID=" line. I'm not sure what the
terms: NameID and " & Me.cboNameID" refer to and think that I may be
substituting the wrong control names in my code.

Me.NameOfSubformControl.SourceObject = "SubFormName"
Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever "
Where NameID = " & Me.cboNameID"

"Arvin Meyer [MVP]" wrote:

[Quoted Text]
> You may not have a reference to DAO. Open any code window and uncheck the
> reference to ActiveX Data Objects (ADO) and check the one marked:
>
> Microsoft DAO 3.6 Object Library
>
> If that still doesn't help, set a breakpoint at:
>
> Set rs = Me.Recordset.Clone
>
> and step through the code (F8) to find the error.
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> news:94FBD955-09CB-4C7E-92A3-B3C88B9BE801[ at ]microsoft.com...
> >I need a bit more help. When I click on a name in the comboBox I get "sub
> >or
> > function not defined." Is the record set code used for the main form
> > causing a problem? Also wasn't sure what tbl Whatever referred to? I've
> > substituted the names of the cbo, subformControl, and NameID and put the
> > following code in the Module: Combobox AfterUpdate:
> >
> > Private Sub Combo7_AfterUpdate()
> > ' Find the record that matches the control.
> > Dim rs As Object
> >
> > Set rs = Me.Recordset.Clone
> > rs.FindFirst "[CountryID] = " & Str(Nz(Me![Combo7], 0))
> > If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> >
> > Me.BRSch.SourceObject = "SubFormName"
> > Me.BRSch.Form.RecordSource = "Select * From tblWhatever"
> > Where NameID = " & Me.BRSch"
> >
> > End Sub
> >
> > When I click on a name in the comboBox I get "sub or function not
> > defined."
> > Is the record set code used for the main form causing a problem? Also
> > wasn't sure what tbl Whatever referred to?
> >
> > "Arvin Meyer [MVP]" wrote:
> >
> >> By changing the Source Object property of the subform control. But it
> >> still
> >> needs to be linked to the main form, or the recordsource has to use the
> >> combobox as a criteria:
> >>
> >> Sub cboNameID_AfterUpdate()
> >> Me.NameOfSubformControl.SourceObject = "SubFormName"
> >> Me.NameOfSubformControl.Form.RecordSource = "Select * From
> >> tblWhatever
> >> Where NameID =" & Me.cboNameID
> >> End Sub
> >>
> >> --
> >> Arvin Meyer, MCP, MVP
> >> http://www.datastrat.com
> >> http://www.mvps.org/access
> >> http://www.accessmvp.com
> >>
> >>
> >> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> >> news:34E6AC4C-FFA0-4064-AE74-909F762876F2[ at ]microsoft.com...
> >> >I wrote code so that when a name in a combo box is clicked on its
> >> > corrosponding form opens but as a separate window. Is it possible to
> >> > get
> >> > the
> >> > form to open as a subform of the form on which the combo box is
> >> > located?
> >> >
> >> > "Evan" wrote:
> >> >
> >> >> I wish this were so easy. I've created a form with a combo box of
> >> >> names
> >> >> linked to a table of names & NameID's (primary key). I've also
> >> >> created
> >> >> the
> >> >> command button: "Go" using: Form Operations > Open form > specific
> >> >> form
> >> >> >
> >> >> open form/show all records. The specific form opens as a separate
> >> >> form.
> >> >> I
> >> >> need the form named in the combo box to open as a subform in the form.
> >> >> How
> >> >> do I do that?
> >> >>
> >> >> "Arvin Meyer [MVP]" wrote:
> >> >>
> >> >> > Evan it is even easier than that. When you select a name from an
> >> >> > unbound
> >> >> > combobox, you can have the form move to that record, and the subform
> >> >> > will as
> >> >> > well.
> >> >> >
> >> >> > Two things that make it very easy. When you add the dropdown list,
> >> >> > use
> >> >> > 2
> >> >> > columns, the ID (primary key) column, and the Name. If you have
> >> >> > wizards
> >> >> > enabled (the magic wand in the toolbox) a dialog will come up to
> >> >> > walk
> >> >> > you
> >> >> > through the process.
> >> >> >
> >> >> > Second, when you add a subform control, from the toolbox, a wizard
> >> >> > will
> >> >> > walk
> >> >> > you through the process and automatically link the form and subform.
> >> >> > --
> >> >> > Arvin Meyer, MCP, MVP
> >> >> > http://www.datastrat.com
> >> >> > http://www.mvps.org/access
> >> >> > http://www.accessmvp.com
> >> >> >
> >> >> >
> >> >> > "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
> >> >> > news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
> >> >> > > I've created a form with a drop-down list, command button and
> >> >> > > subform
> >> >> > > and
> >> >> > > would like to connect the three together. So that when name1 is
> >> >> > > selected
> >> >> > > from the dropdown list and a command button "Go" is clicked
> >> >> > > name1's
> >> >> > > subform
> >> >> > > opens as the subform in the form or if name2 is selected and the
> >> >> > > "go"
> >> >> > > button
> >> >> > > is clicked then name2's subform will appear as the subform. Is
> >> >> > > this
> >> >> > > possible? Can anyone help? I'm assuming that I need to use the
> >> >> > > DoCmd:OpenSubForm and then use an If ElseIf Statement.
> >> >> >
> >> >> >
> >> >> >
> >>
> >>
> >>
>
>
>
Re: Connecting commands on form
"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> 12/31/2008 12:13:49 AM
This code:

Me.NameOfSubformControl.SourceObject = "SubFormName"
Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever "
Where NameID = " & Me.cboNameID"

Should look like this:

Me.NameOfSubformControl.SourceObject = "SubFormName"
Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever _
Where NameID = " & Me.cboNameID

or like this:

Me.NameOfSubformControl.SourceObject = "SubFormName"

Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever
Where NameID = " & Me.cboNameID

Where the second line is all on 1 single line.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
news:3F76EB79-902B-476D-8A41-1B133F183B21[ at ]microsoft.com...
[Quoted Text]
> The error occurs at the "Where NameID=" line. I'm not sure what the
> terms: NameID and " & Me.cboNameID" refer to and think that I may
> be
> substituting the wrong control names in my code.
>
> Me.NameOfSubformControl.SourceObject = "SubFormName"
> Me.NameOfSubformControl.Form.RecordSource = "Select * From tblWhatever
> "
> Where NameID = " & Me.cboNameID"
>
> "Arvin Meyer [MVP]" wrote:
>
>> You may not have a reference to DAO. Open any code window and uncheck the
>> reference to ActiveX Data Objects (ADO) and check the one marked:
>>
>> Microsoft DAO 3.6 Object Library
>>
>> If that still doesn't help, set a breakpoint at:
>>
>> Set rs = Me.Recordset.Clone
>>
>> and step through the code (F8) to find the error.
>> --
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.mvps.org/access
>> http://www.accessmvp.com
>>
>>
>> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
>> news:94FBD955-09CB-4C7E-92A3-B3C88B9BE801[ at ]microsoft.com...
>> >I need a bit more help. When I click on a name in the comboBox I get
>> >"sub
>> >or
>> > function not defined." Is the record set code used for the main form
>> > causing a problem? Also wasn't sure what tbl Whatever referred to?
>> > I've
>> > substituted the names of the cbo, subformControl, and NameID and put
>> > the
>> > following code in the Module: Combobox AfterUpdate:
>> >
>> > Private Sub Combo7_AfterUpdate()
>> > ' Find the record that matches the control.
>> > Dim rs As Object
>> >
>> > Set rs = Me.Recordset.Clone
>> > rs.FindFirst "[CountryID] = " & Str(Nz(Me![Combo7], 0))
>> > If Not rs.EOF Then Me.Bookmark = rs.Bookmark
>> >
>> > Me.BRSch.SourceObject = "SubFormName"
>> > Me.BRSch.Form.RecordSource = "Select * From tblWhatever"
>> > Where NameID = " & Me.BRSch"
>> >
>> > End Sub
>> >
>> > When I click on a name in the comboBox I get "sub or function not
>> > defined."
>> > Is the record set code used for the main form causing a problem? Also
>> > wasn't sure what tbl Whatever referred to?
>> >
>> > "Arvin Meyer [MVP]" wrote:
>> >
>> >> By changing the Source Object property of the subform control. But it
>> >> still
>> >> needs to be linked to the main form, or the recordsource has to use
>> >> the
>> >> combobox as a criteria:
>> >>
>> >> Sub cboNameID_AfterUpdate()
>> >> Me.NameOfSubformControl.SourceObject = "SubFormName"
>> >> Me.NameOfSubformControl.Form.RecordSource = "Select * From
>> >> tblWhatever
>> >> Where NameID =" & Me.cboNameID
>> >> End Sub
>> >>
>> >> --
>> >> Arvin Meyer, MCP, MVP
>> >> http://www.datastrat.com
>> >> http://www.mvps.org/access
>> >> http://www.accessmvp.com
>> >>
>> >>
>> >> "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
>> >> news:34E6AC4C-FFA0-4064-AE74-909F762876F2[ at ]microsoft.com...
>> >> >I wrote code so that when a name in a combo box is clicked on its
>> >> > corrosponding form opens but as a separate window. Is it possible
>> >> > to
>> >> > get
>> >> > the
>> >> > form to open as a subform of the form on which the combo box is
>> >> > located?
>> >> >
>> >> > "Evan" wrote:
>> >> >
>> >> >> I wish this were so easy. I've created a form with a combo box of
>> >> >> names
>> >> >> linked to a table of names & NameID's (primary key). I've also
>> >> >> created
>> >> >> the
>> >> >> command button: "Go" using: Form Operations > Open form > specific
>> >> >> form
>> >> >> >
>> >> >> open form/show all records. The specific form opens as a separate
>> >> >> form.
>> >> >> I
>> >> >> need the form named in the combo box to open as a subform in the
>> >> >> form.
>> >> >> How
>> >> >> do I do that?
>> >> >>
>> >> >> "Arvin Meyer [MVP]" wrote:
>> >> >>
>> >> >> > Evan it is even easier than that. When you select a name from an
>> >> >> > unbound
>> >> >> > combobox, you can have the form move to that record, and the
>> >> >> > subform
>> >> >> > will as
>> >> >> > well.
>> >> >> >
>> >> >> > Two things that make it very easy. When you add the dropdown
>> >> >> > list,
>> >> >> > use
>> >> >> > 2
>> >> >> > columns, the ID (primary key) column, and the Name. If you have
>> >> >> > wizards
>> >> >> > enabled (the magic wand in the toolbox) a dialog will come up to
>> >> >> > walk
>> >> >> > you
>> >> >> > through the process.
>> >> >> >
>> >> >> > Second, when you add a subform control, from the toolbox, a
>> >> >> > wizard
>> >> >> > will
>> >> >> > walk
>> >> >> > you through the process and automatically link the form and
>> >> >> > subform.
>> >> >> > --
>> >> >> > Arvin Meyer, MCP, MVP
>> >> >> > http://www.datastrat.com
>> >> >> > http://www.mvps.org/access
>> >> >> > http://www.accessmvp.com
>> >> >> >
>> >> >> >
>> >> >> > "Evan" <Evan[ at ]discussions.microsoft.com> wrote in message
>> >> >> > news:1E60A0A6-EDE9-4E98-BE43-0F2B16C51407[ at ]microsoft.com...
>> >> >> > > I've created a form with a drop-down list, command button and
>> >> >> > > subform
>> >> >> > > and
>> >> >> > > would like to connect the three together. So that when name1
>> >> >> > > is
>> >> >> > > selected
>> >> >> > > from the dropdown list and a command button "Go" is clicked
>> >> >> > > name1's
>> >> >> > > subform
>> >> >> > > opens as the subform in the form or if name2 is selected and
>> >> >> > > the
>> >> >> > > "go"
>> >> >> > > button
>> >> >> > > is clicked then name2's subform will appear as the subform. Is
>> >> >> > > this
>> >> >> > > possible? Can anyone help? I'm assuming that I need to use
>> >> >> > > the
>> >> >> > > DoCmd:OpenSubForm and then use an If ElseIf Statement.
>> >> >> >
>> >> >> >
>> >> >> >
>> >>
>> >>
>> >>
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net