Full Version: subforms requery
UtterAccess Forums > Microsoft® Access > Access Forms
I have a form on which there is field "fldFormation", it is a combo box. Based on the users selection I want to show more information about the selection in a subform. Using the AfterUpdate event, I can't get the stupid thing to requery so that the additional data is shown. I also want it to know that it is null and show a blank subform.
For AfterUpdate I had
But this didn't work, then I had a loop:
If IsNull(Me!fldFormation) Then
DoCmd.GoToRecord , , acNew
End If
This didn't work either. I think that I have tried about 10 different combos and finally have to admit that I really don't know what I am doing and ask for help... so help, please,
P.S. How is it that the Sox won and I am having such a bad day?
took a quick glance at your post. Here's some handy code I've collected over time. You may be able to apply it.
You may already tried this:
Do you have your subform linked properly?
Hopes this helps you out.
I always use the command "refresh" instead of Requery, as I've had some problems with requery.
lso, I don't know if you've properly identified your other form. Your syntax might be wrong. I think you need to say "form" again before !Requery
THere is an example from Access' Help:
Also, try your command in other events related to the event-button, such as "on close", but test to see if you actually have have data that updated.
I'm just the opposite. I never use refresh. Requery has always worked just fine for me.
From Access Help (2000):
Requery method Updates the data in a Recordset object by re-executing the query on which the object is based.
Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment. The Refresh method shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried. Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.
Thanks everybody. I will dive back in and see if I can get it to work! I'll post what finally works...
Try using the expression in the combos NotInList property
Noah, it depends on the application. Consider when records are isolated - the user has selected a record and is working on it. A popup asks the user for this and that and upon completion (or along the way) refreshes the underlying form. You don't need a requirey as you are working on a specific record, or a selected group of records.
That said, if the application required producing a list of records in that main form, requirey is the way to go.
Thanks for the really clear explanation!
I have the subform tied to the field in the underlying table, so I think my problem is that it isn't sending the information and requerying... in other words it still doesn't work. How would I tie the subform to the combo box or is there something that I am just missing?
Hard to tell like this. Can you attach a copy of your db?
The syntax you have in your first message is not correct. To test your syntax, put a dummy field on your subform called "meTest" and send information from your main form combo to that field in a subform. When you are successful, use that same "path" for your requiry.
You should also check your table to see whether you really passed the information from the combo box to the table so that there is really an after insert event going on. You can always put BEEP in the event to see if it is being arroused.
I actually got frustrated with the subform and took it out. Instead I expanded the fields in my initial combo box query and linked text boxes to the additional fields in the query. I don't know if this makes sense, but it works beautifully since I didn't want people to be able to edit the data. I think my original problem had something to do with linking the subform....
congrats .. always 15 different ways to do the same thing. And yes, syntax for linking seemed to be off.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.