473,327 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Problem Getting Requery to work

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
8 3030
NeoPa
32,556 Expert Mod 16PB
This should help you (How can I refresh a sub form).
Jan 9 '07 #2
Jarekb
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
32,556 Expert Mod 16PB
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
14,534 Expert Mod 8TB
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
32,556 Expert Mod 16PB
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
Jarekb
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
32,556 Expert Mod 16PB
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
32,556 Expert Mod 16PB
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

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

Similar topics

4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
6
by: visionstate | last post by:
Hi there, I am building a database that requires cascading lists on a form. I currently have (I may be adding more later) 3 combo boxes on my form - Department, Surname and Forename. The user...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
2
by: Lyn | last post by:
Hi, I am using a form (FormA) to list the records in a recordset. In the FormA footer, I have an "Add" command button that opens a new form (FormB) modally which is used to input and save a new...
8
by: Cerian | last post by:
Hi there, I'm having trouble getting my 3rd dependent combo box to work in Access 2003. I have three dependent boxes named cbogroup, cbosection and cbofunction. Each one is dependent on the...
2
by: Ron | last post by:
Hi All, I've got a main form (frmMain) with 5 subforms on it. All subforms are linked to different hidden controls on frmMain. The purpose of this form is to record payments by 'source'...
4
by: JHite | last post by:
I am using Access 2003 on Windows XP. This is a simple database that contains “tblStaffers” containing names of the office staffers, “tblProjects” containing names of the office projects, and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.