Refresh Subform Datasheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have perused the knowledge base, and found a lot on refreshing subforms,
but nothing to handle my problem.
I have a master form (Client) with both a subform that is a datasheet with
several products sold to the client (Product_Subform) and a button to open
the Product form to add much more information than what is shown in the
Product_Subform. After I have added my products in the Product form and
close it, I would like the records to show up in the Product_Subform.
I have tried Forms!Client!Product_Subform.Requery in every location I can
think of (On Close in Product form, in the Save and Exit button events on the
Product form, on the Got Focus event in the Client master) nothing seems to
work. I have succesfully requeried other subforms in the same master form,
but they were not datasheets. The closest I got was to get a blank record
added to the datasheet with none of the info.
Please help! My deadline is fast approaching and this is the last issue to
resolve.
Thank you.
 
The correct place to do is in the Close event procedure of the Product form.
Whether the subform is a datasheet or other view should not matter. The
usual problem with this method is that you are not using the correct name of
the subform control (the control that holds the subform) -- be sure that you
have the correct name in your code.
 
Did you try requerying from the AfterUpdate event of the Form where you
entered all the detail data?

Frankly, I don't use datasheet view in developed applications, so I can't
really address that particular aspect. If 'twere me, I'd use a continuous
forms view Form embedded in the Subform Control because I'd have more
control over what goes on.

Larry Linson
Microsoft Access MVP
 
I am afraid I need to use the datasheet view because I need to sort on a
couple of different arguments and datasheet seems to be the best way.
Anyway, I tried the following:
Forms!Client!Product_Subform.Requery
in both On Close and AfterUpdate events on the Product form. For both I get
teh following Runtime error 2118: "You must save the current field before you
run the Requery action."
I actually double-click on a new or existing record in the datasheet to
bring up the Product form. Do I need to move my cursor somewhere first in
the Product_Subform?
Any ideas?
Gregg
 
Ah, it sounds as if you're opening the Product form while the record in the
subform is still "dirty". You probably need to add one line of code in the
command button's code that opens the Product form. Add this line to the code
just before that code opens the Product form:

DoCmd.RunCommand acCmdSaveRecord
 
I finally got this working. I put the Save Record and then the Requery lines
(in that order) in the OnActivate event of the Client master form.
Thanks for your input.
 
Back
Top