By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,041 Members | 1,734 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,041 IT Pros & Developers. It's quick & easy.

Problem Getting Requery to work

P: 3
I've been searching around for a bit and can't find a solution to this problem. I've got a subform that show a list of requests that need to be processed in datasheet view. One of the fields on the subform is a status which is a combo box with three choices (pending, withdrawn, processed). The subform shows the requests that have pending in the status field. When someone changes that status to something besides pending I'd like that record to automatically be deleted from view. Only way I've found thus far to this is by closing/reopening the whole form or using shift+F9.

I did find a few references on the web for the .requery or .refresh commands, but I can't figure out how to use them. Seems each place also has different syntax to make those work. Also I'm not sure if I'm adding the code in the right spot. When I add the code to the form properties under the afterUpdate event I get an error saying "can't find a macro with specified name".... and the macro it can't find is the name of the form.

"Main Form"![status].Requery

That's what I've been trying to work with, not sure if I've got the syntax wrong or putting it in the wrong spot.

Thanks for any help.
Jan 9 '07 #1
Share this Question
Share on Google+
8 Replies


NeoPa
Expert Mod 15k+
P: 31,494
This should help you (How can I refresh a sub form).
Jan 9 '07 #2

P: 3
This should help you (How can I refresh a sub form).
Thats a bit confusing since it looks like the whole code of the form. I'm just using the design view to create this form.

I tried creating a macro that just has Requery under Action and nothing in the control name field. In the sub form's properties under the events tab, I set this macro to the afterUpdate field. This works when I open the subform separately, I change the status to processed and after clicking elsewhere the record disappears from the list. When I go to my main form I get this error when trying to change a record though "You can't use the ApplyFilter action on this window". So I kinda got this to work, but not in my main form. Would any problems be caused by the fact that this whole section is in a tab?
Jan 9 '07 #3

NeoPa
Expert Mod 15k+
P: 31,494
I don't think that the SubForm control being on a tab makes any difference in this case.
Other than that I'm afraid I can't follow what you're saying at all :(
Jan 9 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
I've been searching around for a bit and can't find a solution to this problem. I've got a subform that show a list of requests that need to be processed in datasheet view. One of the fields on the subform is a status which is a combo box with three choices (pending, withdrawn, processed). The subform shows the requests that have pending in the status field. When someone changes that status to something besides pending I'd like that record to automatically be deleted from view. Only way I've found thus far to this is by closing/reopening the whole form or using shift+F9.

I did find a few references on the web for the .requery or .refresh commands, but I can't figure out how to use them. Seems each place also has different syntax to make those work. Also I'm not sure if I'm adding the code in the right spot. When I add the code to the form properties under the afterUpdate event I get an error saying "can't find a macro with specified name".... and the macro it can't find is the name of the form.

"Main Form"![status].Requery

That's what I've been trying to work with, not sure if I've got the syntax wrong or putting it in the wrong spot.

Thanks for any help.
Assuming your query behind the subfom only returns records where status is Pending then a requery of the subform will change the records shown and remove any records that have had their status changed.

Therefore in the After Update Event of the status control box on the subform you would need something like the following VBA code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Status_AfterUpdate()
  2.  
  3.    Forms![MainFormName]![SubFormObjectName].Form.Requery
  4.  
  5. End Sub
  6.  
Mary
Jan 12 '07 #5

NeoPa
Expert Mod 15k+
P: 31,494
Thats a bit confusing since it looks like the whole code of the form. I'm just using the design view to create this form.

I tried creating a macro that just has Requery under Action and nothing in the control name field. In the sub form's properties under the events tab, I set this macro to the afterUpdate field. This works when I open the subform separately, I change the status to processed and after clicking elsewhere the record disappears from the list. When I go to my main form I get this error when trying to change a record though "You can't use the ApplyFilter action on this window". So I kinda got this to work, but not in my main form. Would any problems be caused by the fact that this whole section is in a tab?
You weren't supposed to look at just the first post!
The info, repeated here by Mary, is contained and explained in post #2.
Jan 12 '07 #6

P: 3
I don't think that the SubForm control being on a tab makes any difference in this case.
Other than that I'm afraid I can't follow what you're saying at all :(
The problem I had was not knowing that you could click the "..." button in the properties and select code builder. Once I figured this out, I just added Me.Requery in the code for On Change. Now it works fine. Does it matter if I put that code under On Change or After Update events?
Jan 16 '07 #7

NeoPa
Expert Mod 15k+
P: 31,494
That's a good question.
Now I need to go and check on that. We need the event which triggers when updates are completed on that control, not one that triggers after a character is added.
Jan 16 '07 #8

NeoPa
Expert Mod 15k+
P: 31,494
The problem I had was not knowing that you could click the "..." button in the properties and select code builder. Once I figured this out, I just added Me.Requery in the code for On Change. Now it works fine. Does it matter if I put that code under On Change or After Update events?
OnChange triggers after every change to the contents, so would not be appropriate for you. You need to move it to the AfterUpdate event procedure. This is created just as easily (with the ... button etc).
Jan 16 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.