Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh subform

Status
Not open for further replies.

rider99

Programmer
May 29, 2002
10
US
I have a bug on my subform. The main form is called [frmgroup] and the subform is called[subform], they are linked by group_No.
There are three filed on the subform. When I click a button on the subform, it will go to another table, look up some data based on valuesin field 1 and 2,then update filed3 on the subform.
My problme is that I have to click twice in oroder to get the correct value updated on filed3. I debug the code, it seems that the table behind the subform has been updated correctly after the first click, but won't reflect the change on the subform.
I think I need to reload the form behind the scence in order to show the change. But I don't know how to reload/requery a form/subform. Can anybody help me?
 
Forms!NameOfMainForm!NameOfControlThatHoldsTheSubform.Form.Requery.

You'll have to change the names. Note that it's NOT the name of the subform, it's the name of the control that holds it, though you can certainly have them be the same.

But I'm not sure that's the issue. If you post your code maybe someone will see a problem with it.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Thank you for the reply. But I think the problem is more than that.(sorry to confuse you).
1. The button on the subform will go out and update the table underneath that subform. Here is the code for clicking the button:
Private Sub cmdpremimupdate_Click()
DoCmd.Hourglass True
DoCmd.Echo True

Call updateRecord("premium", "1",temp_fromDate, temp_toDate)
Me.Requery

2. When it runs to me.requery. It always gives me a warning message saying that :another user has changed the data, do I want to change or deline the change. Once I click yes, the error message goes away, but the data on the subform(field3) won't change.
3. Even I close the whole form and reopen it, the data won't change.
4. If I reclick the button again, it gives me the right value without showing the warming message.
5. My temporary solution for now is that call the "updaterecord" function again after me.requery, as if the user click the button again.

But that is not an ultimate solution, but do you know why this happends?
 
Yeah, it would have been helpful to have all of that information the first time around. The error message you mention is because you're editing a record on a bound form at the same time that you're editing that record in code, or through a stored action query.

There's probably a better way to go about it. You'll have to post back describing what it is you're trying to do, and give us the code called in this line:
Call updateRecord("premium", "1",temp_fromDate, temp_toDate)

You'll likely have to save the record (there's a runcommand constant to do that in code) before calling your code. Or maybe there's a way to make the code only affect values in controls on the form, so that all the editing is happening in one place.

Also, I just put up a post about how to get helpful answers. Take a look at that (it's in my sig, now).

Jeremy =============
Jeremy Wallace AlphaBet City Dataworks
See the Developers' section for some helpful fundamentals.

See thread181-473997 for information on how to get the best responses possible here at Tek-Tips.
 
You made a great point here, that I am trying to edit a table behind the form while I am having the bounded form open. So I just made a change.
I close the form before I call that function:
Call updateRecord("premium", "1",temp_fromDate, temp_toDate)
after that I open the form again.
This works.
Sorry that I didn't post the code of that function, because it is too long.

Thank you so much for your help. Hope I can help others like what you did.

Grace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top