Still Stuck in a Hole

e2cheng

Registered User.
Local time
Today, 14:00
Joined
Dec 13, 2002
Messages
72
Goal:
Display updated subform after a query is performed

Situation

main form with button and subform on it
- when button pressed query by form executed and subform based on results form the query should show up

there's a line of code i've been using for this:

me.subform.requery

technically, it should update and output the correct stuff right??

Current Result

Currently, i'm getting the old results there and nothing is happeneding.

However: (when i close the form and open it back up) or (switch to design view and switch back to form view) it displays the right data. which leads me to think that it's not refreshing properly

can anyone help???

Thanks so much for any pointers!
 
You could try:

[YourFormName]!YourSubFormName.requery
or try
refresh
 
thank you for the reply.

i've been trying the requery function as well as refresh, but none seem to do the trick. the only one that works is closing the form then reopening it. but that's not a good solution.

is there some special property that i'm missing that can't be combined with the requery function?? i created the form with a query. someone suggested that i change the name so that the source object is different fromt eh name, that didn't seem to help either tho...

any other ideas??? thanks once again for your help!
 
When you say "me.subform.requery" do you mean literally? Do you put in "subform" or the name of your subform object, like "mysubform"? Here is some code that does exactly what you're looking for in my form:

Private Sub cmd_Requery_Click()

'Here I rewrite the sql at runtime
Me.Child_Summary.Form.RecordSource = "SELECT Tbl_Fish.Cohort...;"

'The name of the subform object is Child_Summary
Me.Child_Summary.Requery
End Sub


The subform itself is named "fsub_Summary" but the control object in the main form is called "Child_Summary."

Hope that helps,

Matt
 
subform properties(from main form):

Name: ResultsPage
Source Object: MatchingEntries

the name of the subform is: MatchingEntries

if i use Me.MatchingEntries.Requery, i get a compile error with "method or data member not found"

if i use Me.ResultsPage.Requery, nothing appears to happen.

The only way that it will work is if the form is loaded again.

either I go to design view and load the form again in form view OR i close the form and open it again and it will be requeryed/refreshed...

really bothering me.. it's been days...

Thank you for your responding though.
 
subform properties(from main form):

Name: ResultsPage
Source Object: MatchingEntries

the name of the subform is: MatchingEntries

if i use Me.MatchingEntries.Requery, i get a compile error with "method or data member not found"

if i use Me.ResultsPage.Requery, nothing appears to happen.

The only way that it will work is if the form is loaded again.

either I go to design view and load the form again in form view OR i close the form and open it again and it will be requeryed/refreshed...

really bothering me.. it's been days...

Thank you for your responding though.
 
solved!

my stupidity...

i had another problem saving entries. after someone kindly pointed out my syntax errror, that problem along with this one was resolved.

Thank you once again for your help!
 
you're not going to like this...

my bad, my bad... it didn't work. i was under the impression of false hope...

back to the same problem.. only way to get that to requery is to close the form, then reload...
 
Not the best solution in the world but..
you could switch to design view then straight back to normal view using code - the user wouldnt know as it would be almost instant.
 
"if i use Me.MatchingEntries.Requery, i get a compile error with "method or data member not found" "
means that MatchingEntries is not the name of your subform , open the main form in design view, click on the subform control, open the property sheet and click the "Other" tab, the correct name to reference will be there
 
I suggest

Forms!YourFormName!YourSubFormControlName.Form.Requery

hth

shay :cool:
 
hi rich,

Thank you for your response. these are a few cases i've been trying...

from the properties window of the subform in the main form:

Name : ResultsPage
Object Source: MatchingEntries

From the datbase window, under forms:
MatchingEntries is the name of my subform (is this maybe where the problem is??) ... I just tried renaming this form MainSubform, but that doesn't seem to do the trick either.

at any rate, if i use

  • Me.ResultsPage.Requery ' nothing appears to happen until page reloaded
  • Me!ResultsPage.Requery ' nothing appears to happen until page reloaded
  • Me!MatchingEntries.Requery ' error msg: Run-time error '2465': MS Access can't find the field 'MainSubform' referred to in your expression. HOWEVER; if i end the operation and reload the form, the correct infomation appears as well.
  • Me.MatchingEntries.Requery ' error msg: Compile error: Method or data not found. on the reload, the subform does NOT update.
  • the only sulotion that sems to work..
    call cmdClose_Click()
    docmd.openform "Main"
    but that's not very good...

thank you for your response..
 
hi shay,

thank you for your response as well. i just gave that a try. but the control name you mean the name from the properties window of the main form right??
 
No, I don't mean the name of your subform (which is what you see in the main database window). You must use the name of the subform control.

Look at the Name property of the subform when you have your main form open in design mode.

hth

shay :cool:
 
yep, that's the one i tried. from the main form page, not the main database window. my bad for the confusion, i tried the one from the main database window as well that just gave me errors; but yeah, i've been using the namecontrol in the properties window.

thanx again for the rep! much appreciated
 
Hi

Have you used the same name for the subform and for the name of the subform control? If yes, I'd suggest changing one of them.

Are you sure you've included the .Form before the .Requery in your code? It isn't optional!

Lastly what version of Access are you using because the code I suggested works perfectly in A97. I've used Access for years and I've never had to close and reopen a form to get a subform to refresh.

shay :cool:
 
hi shay,

thank you once again for your help.

1. same name for subform and subform control
- that has been changed, someone mentioned that the wiward automatically assigns that but is known to cause problems.

2. .Form before .Requery
- thank you for that tip. i have changed that after reading your post.

3. version
- i'm using access 2000, but if anything the code should be the same.

do you think the problem may be with the way data is passed/used.

here is the flow of data. simplified

essentially one table, one form. the record source for my form is that table. on that same form, i have a tab that allows the user to enter data into unbound txtboxes with fields corresponding to the defined table. on a button click, i then do a query by form and wire the results to this subform. and i'm trying to output the subform... i did the same for output to report and that works fine. but i think it's cause that is being loaded on command...

thank you once again for all your help!

peace,
eric
 
Eric

Sorry but it's really not clear to me how you're going about this - for example you say you
wire the results to this subform. and i'm trying to output the subform
- it's not easy for an outsider to understand exactly what steps you are taking.

If you can strip out all but the essential stuff and post the db I can have a look.

shay :cool:
 
thank you

hi shay,

thank so you so much taking time to look at this.. i've cut out a bunch of stuff, so it's a decent size..

sorry for all the confusing ealier...

anyways, the problem is when you try and try and find... so let's say you want to find all the concrete samples, so
- go to find tab
- select custom search
- select C from group
- click find
* brings you to the matching entries page, but not updated..

the function it goes through is cmdFind_click() which is refered to Subroutine doSearch at the end of doSearch you'll see my retarded code idea of closing and opening the form..

Thank you so mcuh for your help,
eric

http://www.geocities.com/eocheng/test.mdb
 

Users who are viewing this thread

Back
Top Bottom