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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh entire form when data in one control is updated

Status
Not open for further replies.

Imstac73

Programmer
Aug 11, 2008
10
US
I have a continuous form (Timecard Entry) in which I have unbound controls in the header that users enter data. The unbound controls are the default values for bound controls in the details section. Any time the unbound controls are updated I would like the entire form to refresh so that the detail controls will update with any changes.

I have tried all the following on the AfterUpdate event and none of them work:

docmd.Sendkeys "+{F9}"
Me.Requery
Me![Timecard Entry].Requery

Am I using the wrong commands?
 
on afterupdate try:

me!Boundontrol=me![red]un[/red]BoundControl

BUT-Do you really want to do this?
 
I'm not sure I understand the purpose of the code you posted. My reasoning for wanting to refresh the form after changing the unbound controls (empl id, w/e date, week number) is in case the user keys several lines and then realizes afterward that they had the wrong employee or w/e date. If there are any changes in the bound controls it should automatically update all of the detail lines below.
 
gotcha:

Code:
dim db as database
dim rs as recordset

set db=currentdb
set rs=db.openrecordset("QueryThatGetDataInForm",dbopendynaset0

rs.movefirst
do until rs.eof
   rs.edit
      rs!weDate=forms!YourForm!YourWEDate
      rs!NextField=forms!YourForm!YournextField
      ...
   rs.update
   rs.movenext
loop
me.requery

Am I closer this time?
 
Do I have to do all this code just to get the form to refresh when there is a change in the fields? It works if I hit the Refresh All button from the toolbar but I don't want the users to have to remember to do this.
 
if the 'bound' controls in the main section are truly bound they shouldn't behave that way. Once the values are stored they should stay that way unless you use code similar to above.

is it the default value you want to change?

If you have this:

1/1/2008 1
===============

as w/e and w/number in header, and this in main form:

2/1/2008 1
3/1/2008 1
...
10/1/2008 2

then what do you want to happen exactly?

I promise I'm not being difficult, just think I must have wrong idea about your request!
 
In my header section there is an unbound employee ID field in which the user keys in the employee id.


In the details section there is another employee id field that is bound to my table. The default value of this field is set to the unbound field.

What I want to happen is the user keys in the employee id in the unbound and it should automatically update the bound field in the details section. The user will key in all the fields in the details section and hit the Add Record button. They will key in as many records as needed for that employee. Once they have keyed in all records for that employee they will go back up to the unbound field in the header section and key in the next employee id. When they do this I would like the bound field below to refresh so it will populate with the new employee id.

I hope I am explaining this correctly. Thanks.
 
Okay, so I decided to use a single form instead of a continuous form but I still can't get any of the refresh commands to work. The only thing that works is to hit the Refresh All button from the Access toolbar.

One of my unbound controls is Employee ID located in the header section. Employee ID is set up to be the default value of my bound field in my details section. I've tried the following code on each of these events: 'On Lost Focus', 'On Change', 'On exit' and nothing seems to work.

Forms![Timecard Entry2]![INEENO].Refresh

Me.Refresh
Me.Repaint

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top