422,530 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,530 IT Pros & Developers. It's quick & easy.

unbound subform not working correctly

P: n/a
I have a form (Worksheet) that works fine by itself. I have now created a
seperate form (MainForm) that has a command button in the header and an
unbound subform (FormFrame) in the Detail section. when the user clicks the
command button, Worksheet is loaded into the subform control. At this point,
some of the functions do not work. The user is prompted to enter a Parameter
Value. Why wouldn't that form (Worksheet) work the same as a sub form? There
are no controls from or references to anthing on Worksheet on the MainForm
form, other than loading it from the command button. What am I not
understanding?
May 28 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Robert" <no**@email.com> wrote in
news:kl********************@fe03.news.easynews.com :
I have a form (Worksheet) that works fine by itself. I have
now created a seperate form (MainForm) that has a command
button in the header and an unbound subform (FormFrame) in the
Detail section. when the user clicks the command button,
Worksheet is loaded into the subform control. At this point,
some of the functions do not work. The user is prompted to
enter a Parameter Value. Why wouldn't that form (Worksheet)
work the same as a sub form? There are no controls from or
references to anthing on Worksheet on the MainForm form, other
than loading it from the command button. What am I not
understanding?

When a form is married into a main form, she looses her maiden name
and becomes known as Form!mainformname!controlname

Somewhere in the query that you are using as source for the
subform is a reference to its name, which is no longer valid.

--
Bob Quintal

PA is y I've altered my email address.
May 28 '06 #2

P: n/a
This fixed part of the problem. I changed all of the references in the
underlying query to Forms!MainFormName!ControlName and I no longer get that
error, but I alos don't get the results I'm supposed to. What happens on the
form is, user selects a client name in a combo box which triggers a second
combo box of projects to display open projects for that client. On the
original form this worked but now, with the change to the query's criteria,
nothing appears in the list of projects. I am assuming that any references
in the code for these controls to "Me!ControlName.method" would still be
accurate and not need to be renamed.

"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
"Robert" <no**@email.com> wrote in
news:kl********************@fe03.news.easynews.com : When a form is married into a main form, she looses her maiden name
and becomes known as Form!mainformname!controlname

Somewhere in the query that you are using as source for the
subform is a reference to its name, which is no longer valid.

--
Bob Quintal

PA is y I've altered my email address.

May 28 '06 #3

P: n/a
"Robert" <no**@email.com> wrote in
news:Ii*****************@fe09.news.easynews.com:
This fixed part of the problem. I changed all of the
references in the underlying query to
Forms!MainFormName!ControlName and I no longer get that error,
but I alos don't get the results I'm supposed to. What happens
on the form is, user selects a client name in a combo box
which triggers a second combo box of projects to display open
projects for that client. On the original form this worked but
now, with the change to the query's criteria, nothing appears
in the list of projects. I am assuming that any references in
the code for these controls to "Me!ControlName.method" would
still be accurate and not need to be renamed.

those references using me. should still work. Without careful
examination of the code and the queries, it's difficult to say
what the problem is, but I have built several working unbound
forms with cascading comboboxes that filter a subform
"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
"Robert" <no**@email.com> wrote in
news:kl********************@fe03.news.easynews.com :

When a form is married into a main form, she looses her
maiden name and becomes known as
Form!mainformname!controlname

Somewhere in the query that you are using as source for the
subform is a reference to its name, which is no longer valid.

--
Bob Quintal

PA is y I've altered my email address.



--
Bob Quintal

PA is y I've altered my email address.
May 28 '06 #4

P: n/a
Bob Quintal wrote:
When a form is married into a main form, she looses her maiden name
and becomes known as Form!mainformname!controlname


Grumpy old men do not use this archaic and ugly naming convention. They
ensure the form has a module (code) and happily refer to it as
Form_FormName, and to its properties and events as
Form_FormName.PropertyorEvent anywhere, anytime.

May 29 '06 #5

P: n/a
OK, here are the details that seem relevent to me. I have poured over the
various controls and code and can't find anything that seems wrong, so I can
only assume that there is either a glaring error that is to obvious for me
to see, or a minor detail that I am not knowlegable enough to spot...

My main form [frmMainMenu] has a header with a series of command buttons,
the relevent one being [WorksheetButton]. The form detail contains two
unbound subforms, one named [FormFrame] the other [SecondaryFormFrame]. When
the user clicks [WorksheetButton], the SourceObject of [FormFrame] is set to
[frmWorksheet]:

Me!FormFrame.SourceObject = "frmWorksheet"

On the subform - [frmWorksheet] there is a header with two combo box
controls. The first is [SelectClient] which is populated from a query
"qryClientList":

SELECT tblClients.Client, tblClients.ClientID, tblClients.HomePhone,
tblClients.OfficePhone, tblClients.CellPhone,
tblClients.Location FROM tblClients ORDER BY tblClients.Client;

This combo contains a list of all the clients from "tblClients". Once a user
selects a client, the OnUpdate event triggers:

Me!SelectProject.Enabled = True
Me!SelectProject.Requery
EnableControls Me, acDetail, False

This enables the second combo box control [SelectProject] and is supposed to
populate it with a list of projects associated with the client chosen in the
first combo. The datasource is a query "qryProjectsByClient":

SELECT tblProjects.Project, tblProjects.ProjectID, tblProjects.ClientID,
tblProjects.Status
FROM tblProjects WHERE
(((tblProjects.ClientID)=[Forms]![frmMainMenu]![SelectClient]) AND
((tblProjects.Status) ="Pending" Or (tblProjects.Status)="In
Progress"));

Problem is, I see the list of clients in the SelectClient control, I select
a name and the screen flickers (as it does when it requeries) but nothing
appears in the SelectProject control. I don't thing it ever gets to this
point but, the AfterUpdate event for the SelectProject controls is:

DoCmd.ApplyFilter , "ProjectID = Forms!frmMainMenu!SelectProject"
EnableControls Me, acDetail, True
Me!ProjectID.Enabled = False

When I had this form open as a stand alone form (before I changed the form
references in "qryProjectsByClient" and the AfterUpdate event, these events
worked perfectly. I have checked all of the code in frmWorksheet and all of
the datasources and there is no other references to "frmWorksheet" that I
can find.

Do you see something in the code above that could present a problem? or is
there someplace else that I should look? I am afraid that I have tapped out
my pool of knowledge, so any help would be greatly appreciated.

"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn*********************@207.35.177.135...
"Robert" <no**@email.com> wrote in
news:Ii*****************@fe09.news.easynews.com:

those references using me. should still work. Without careful
examination of the code and the queries, it's difficult to say
what the problem is, but I have built several working unbound
forms with cascading comboboxes that filter a subform

May 29 '06 #6

P: n/a
"Robert" <no**@email.com> wrote in
news:lz********************@fe04.news.easynews.com :
OK, here are the details that seem relevent to me. I have
poured over the various controls and code and can't find
anything that seems wrong, so I can only assume that there is
either a glaring error that is to obvious for me to see, or a
minor detail that I am not knowlegable enough to spot...

My main form [frmMainMenu] has a header with a series of
command buttons, the relevent one being [WorksheetButton]. The
form detail contains two unbound subforms, one named
[FormFrame] the other [SecondaryFormFrame]. When the user
clicks [WorksheetButton], the SourceObject of [FormFrame] is
set to [frmWorksheet]:

Me!FormFrame.SourceObject = "frmWorksheet"

On the subform - [frmWorksheet] there is a header with two
combo box controls. The first is [SelectClient] which is
populated from a query "qryClientList":

SELECT tblClients.Client, tblClients.ClientID,
tblClients.HomePhone,
tblClients.OfficePhone, tblClients.CellPhone,
tblClients.Location FROM tblClients ORDER BY
tblClients.Client;

This combo contains a list of all the clients from
"tblClients". Once a user selects a client, the OnUpdate event
triggers:

Me!SelectProject.Enabled = True
Me!SelectProject.Requery
EnableControls Me, acDetail, False

This enables the second combo box control [SelectProject] and
is supposed to populate it with a list of projects associated
with the client chosen in the first combo. The datasource is a
query "qryProjectsByClient":

SELECT tblProjects.Project, tblProjects.ProjectID,
tblProjects.ClientID,
tblProjects.Status
FROM tblProjects WHERE
(((tblProjects.ClientID)=[Forms]![frmMainMenu]![SelectClient])
AND ((tblProjects.Status) ="Pending" Or
(tblProjects.Status)="In Progress"));
well, if I understand the hiearchy, SelectClient isn't on the
parent form directly.but in the frmframe control.

This implies it is: [Forms]![frmMainMenu]![SelectClient]

Its fully qualified name is
Forms![frmMainMenu]![frmframe].form![SelectClient] (unwrap the
line if necessary)

Hope this helps.

Problem is, I see the list of clients in the SelectClient
control, I select a name and the screen flickers (as it does
when it requeries) but nothing appears in the SelectProject
control. I don't thing it ever gets to this point but, the
AfterUpdate event for the SelectProject controls is:

DoCmd.ApplyFilter , "ProjectID =
Forms!frmMainMenu!SelectProject" EnableControls Me,
acDetail, True Me!ProjectID.Enabled = False

When I had this form open as a stand alone form (before I
changed the form references in "qryProjectsByClient" and the
AfterUpdate event, these events worked perfectly. I have
checked all of the code in frmWorksheet and all of the
datasources and there is no other references to "frmWorksheet"
that I can find.

Do you see something in the code above that could present a
problem? or is there someplace else that I should look? I am
afraid that I have tapped out my pool of knowledge, so any
help would be greatly appreciated.

"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn*********************@207.35.177.135...
"Robert" <no**@email.com> wrote in
news:Ii*****************@fe09.news.easynews.com:

those references using me. should still work. Without careful
examination of the code and the queries, it's difficult to
say what the problem is, but I have built several working
unbound forms with cascading comboboxes that filter a subform


--
Bob Quintal

PA is y I've altered my email address.
May 29 '06 #7

P: n/a
Ok, changing that syntax in the query worked. I'm not entirely sure why the
change was needed but we can get to that later.

Now the SelectProject list is populated correctly, however, once I make a
selection I get an error: Runtime error 2491 which says that the action is
invalid because the form isnt open or isnt based on a table or query. THis
is correct if it is refering to the main form (frmMainMenu) but not the
subform (frmWorksheet) which is based on tblProjects with the filter:

ProjectID = Forms!frmMainMenu!SelectProject

I tried to change that to the syntax you provided earlier but to no avail.
Also, upon debugging the error, Access hightlights the following line of
code in the AfterUpdate event of SelectProject:

DoCmd.ApplyFilter , "ProjectID = Forms!frmMainMenu!SelectProject"

I tried changing the syntax of this line also with no success.

When I'm in the code editor, if I press the Go button I get another runtime
error - 2488 "You cant use the ApplyFilter action on this window". I'm not
sure what this is about.

It seems as though Access is telling me that I need to have my main form
based on a table. I am confused however, because the main form does not
actually use any information, it is simply a means for display. Can I/Should
I just base the form on a table or query such as tblProjects like the
subform is but not use any controls from that table in the main form? As a
side note, at a future time, I am planning to develop a timecard application
that would concievably be loaded into that same FormFrame subform. Would
setting frmMainMenu's recordsource to tblProjects cause trouble when I do
create the timecard feature?

Robert

P.S. thanks for the patience!


"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
"Robert" <no**@email.com> wrote in
news:lz********************@fe04.news.easynews.com :

well, if I understand the hiearchy, SelectClient isn't on the
parent form directly.but in the frmframe control.

This implies it is: [Forms]![frmMainMenu]![SelectClient]

Its fully qualified name is
Forms![frmMainMenu]![frmframe].form![SelectClient] (unwrap the
line if necessary)

Hope this helps.

May 29 '06 #8

P: n/a
"Robert" <no**@email.com> wrote in
news:Oz*******************@fe09.news.easynews.com:
Ok, changing that syntax in the query worked. I'm not entirely
sure why the change was needed but we can get to that later.
Understanding why it works is key in helping you find/fix your
other problems. Basically, every object in Access fits in to a
hierarchy. At the top is the .application. beneath that are the
collections of tables, queries, forms, reports and modules.
Controls: Textboxes, listboxes, etc, labels and such are below
those.
Forms and reports can have subforms and subreports. Those are
also controls.

The name of an object is the nested path down through the
hiearchy. The first part is Forms, then comes the actual name of
the form. Next is the property or the control

Forms![frmMainMenu]![frmframe] is the reference to the subform
control. Adding the.form after lets us a reference the subform
properties, and objects. Then we specify which control on the
subform, then we would specify the property of that control we
want to examine, say forecolor or value. Value is the defauklt
property so leaving it off the list gives us the same result as
adding it.

Forms![frmMainMenu]![frmframe].form![SelectProject].value
Now the SelectProject list is populated correctly, however,
once I make a selection I get an error: Runtime error 2491
which says that the action is invalid because the form isnt
open or isnt based on a table or query. THis is correct if it
is refering to the main form (frmMainMenu) but not the subform
(frmWorksheet) which is based on tblProjects with the filter:

ProjectID = Forms!frmMainMenu!SelectProject
Well, the line above *is* pointing to the unbound form, so it's
a valid error.

Where is the above line? if it's in the
SelectProject_afterUpdate Event, it should work.
You could also try using the Me. prefix, which in a form or
subform, refers to the current level.

ProjectID = me.SelectProject

If it's in the query, you need to use the long version because
me. would be referring to the query,
I tried to change that to the syntax you provided earlier but
to no avail. Also, upon debugging the error, Access
hightlights the following line of code in the AfterUpdate
event of SelectProject:

DoCmd.ApplyFilter , "ProjectID =
Forms!frmMainMenu!SelectProject"

I tried changing the syntax of this line also with no success.
try the Me.SelectProject again.
When I'm in the code editor, if I press the Go button I get
another runtime error - 2488 "You cant use the ApplyFilter
action on this window". I'm not sure what this is about.
Neither do I at this instance, probably because the code is
pointing to a property on the mainform which has no records to
filter instead of the subform you are trying to set it on.
It seems as though Access is telling me that I need to have my
main form based on a table. I am confused however, because the
main form does not actually use any information, it is simply
a means for display. Can I/Should I just base the form on a
table or query such as tblProjects like the subform is but not
use any controls from that table in the main form? As a side
note, at a future time, I am planning to develop a timecard
application that would concievably be loaded into that same
FormFrame subform. Would setting frmMainMenu's recordsource to
tblProjects cause trouble when I do create the timecard
feature?
Doing that would be counterproductive. You can figure it out,
and get it to work. As the wise old man said: "Patience,
Grasshopper!"

Robert

P.S. thanks for the patience!


"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
"Robert" <no**@email.com> wrote in
news:lz********************@fe04.news.easynews.com :

well, if I understand the hiearchy, SelectClient isn't on the
parent form directly.but in the frmframe control.

This implies it is: [Forms]![frmMainMenu]![SelectClient]

Its fully qualified name is
Forms![frmMainMenu]![frmframe].form![SelectClient] (unwrap
the line if necessary)

Hope this helps.



--
Bob Quintal

PA is y I've altered my email address.
May 30 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.