requery continuour subform

C

CuriousMark

I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
D

Douglas J. Steele

Try renaming the subform control to remove the space, then refer to the
corrected name.
 
J

Jeanette Cunningham

Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on the
wrong form and spent time trying to debug it - took quite a while to realise
that I had the code on the wrong form - that's what late nights spent coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

CuriousMark

checked again. I have another subform on the same form with a space in the
name and for which this worked. Tried again and it worked. Not sure what's
different this time though. Thanks.
CM

Jeanette Cunningham said:
Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on the
wrong form and spent time trying to debug it - took quite a while to realise
that I had the code on the wrong form - that's what late nights spent coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


CuriousMark said:
I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
C

CuriousMark

OK...figured out the problem.
The statement that is giving me the problem is:

DoCmd.GoToRecord acDataForm, "CaseHistory", acLast

(notice, I removed the space). This gives me the object is not open error.



Jeanette Cunningham said:
Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on the
wrong form and spent time trying to debug it - took quite a while to realise
that I had the code on the wrong form - that's what late nights spent coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


CuriousMark said:
I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
C

CuriousMark

Thanks Doug. Please see my other response. Turns out the requery statement is
not the problem. Instead I'm having trouble with the DoCmd statement.

Douglas J. Steele said:
Try renaming the subform control to remove the space, then refer to the
corrected name.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


CuriousMark said:
I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
J

Jeanette Cunningham

Do you want the subform to show the newly added record after the subform is
requeried?
Perhaps best if you explain the scenario - what are you doing to the forms
that makes a requery of the subform necessary?
We can recommend something appropriate for the situation.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


CuriousMark said:
OK...figured out the problem.
The statement that is giving me the problem is:

DoCmd.GoToRecord acDataForm, "CaseHistory", acLast

(notice, I removed the space). This gives me the object is not open error.



Jeanette Cunningham said:
Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on
the
wrong form and spent time trying to debug it - took quite a while to
realise
that I had the code on the wrong form - that's what late nights spent
coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


CuriousMark said:
I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code
in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
J

John W. Vinson

On Mon, 21 Sep 2009 15:07:02 -0700, CuriousMark

A Subform isn't "open" in this sense. It's not part of the Forms collection so
the DoCmd can't find int.

Try

DoCmd.GoToRecord acDataForm, "Forms!frmEncounter![Case History].Form", acLast

--

John W. Vinson [MVP]
OK...figured out the problem.
The statement that is giving me the problem is:

DoCmd.GoToRecord acDataForm, "CaseHistory", acLast

(notice, I removed the space). This gives me the object is not open error.



Jeanette Cunningham said:
Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on the
wrong form and spent time trying to debug it - took quite a while to realise
that I had the code on the wrong form - that's what late nights spent coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


CuriousMark said:
I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
C

CuriousMark

Didn't work. Still get "object isn't open" error.

John W. Vinson said:
On Mon, 21 Sep 2009 15:07:02 -0700, CuriousMark

A Subform isn't "open" in this sense. It's not part of the Forms collection so
the DoCmd can't find int.

Try

DoCmd.GoToRecord acDataForm, "Forms!frmEncounter![Case History].Form", acLast

--

John W. Vinson [MVP]
OK...figured out the problem.
The statement that is giving me the problem is:

DoCmd.GoToRecord acDataForm, "CaseHistory", acLast

(notice, I removed the space). This gives me the object is not open error.



Jeanette Cunningham said:
Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on the
wrong form and spent time trying to debug it - took quite a while to realise
that I had the code on the wrong form - that's what late nights spent coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
C

CuriousMark

I'll try in brief, using an order-entry analogy:
frmEncounter is used for entering orders. Each order has several products. I
wanted to be able to see the previous orders in the same window I am using to
enter new orders, so I created the subfrmCaseHistory. This form is a
continuous form based on a query that shows all orders listed
chronologically, but each order with only one of the products (the most
expensive product in the order). To make it more useful, when the
subfrmCaseHistory opens it uses GoToRecord,, acLast to automatically scroll
to the bottom of the list so that most recent orders are shown.

When I enter a new order, I want subfrmCaseHistory to show the new order at
the bottom of the list. So I want to execute a requery for the form and redo
the DoCmd.GoToRecord,,acLast. I can get the execute the requery, but the
GoToRecord gives me the error.

Jeanette Cunningham said:
Do you want the subform to show the newly added record after the subform is
requeried?
Perhaps best if you explain the scenario - what are you doing to the forms
that makes a requery of the subform necessary?
We can recommend something appropriate for the situation.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


CuriousMark said:
OK...figured out the problem.
The statement that is giving me the problem is:

DoCmd.GoToRecord acDataForm, "CaseHistory", acLast

(notice, I removed the space). This gives me the object is not open error.



Jeanette Cunningham said:
Hi CuriousMark,
check carefully for the correct name for the subform control. If that
doesn't work try this long shot. Make sure that the code to requery the
subform is on the main form that actually has this subform.
I was once caught by this type of thing, I had put the requery code on
the
wrong form and spent time trying to debug it - took quite a while to
realise
that I had the code on the wrong form - that's what late nights spent
coding
can do to you.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code
in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 
D

Douglas J. Steele

Me.[frmEncounter] doesn't look correct to me, Karl.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


KARL DEWEY said:
What about --
Me.[frmEncounter]![Case History].Requery

--
Build a little, test a little.


CuriousMark said:
I've looked throught discussion groups, and can't find the solution:

I have a main form (frmEncounter) with a subform. The subform control's
name
is "Case History" and its source object is "subfrmCaseHistory".
subfrmCaseHistory is based on a simple query. I have tried writing code
in
the main form module to requery the subform and refresh the data:

Me![Case History].Form.Requery
Me.[Case History].Requery

but I get this error:

2489: The object 'Case History' isn't open

What's wrong?
Thanks
 

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