DoCMd Refresh

tezread

Registered User.
Local time
Today, 18:42
Joined
Jan 26, 2010
Messages
330
I have a form frmPatient which has a sub form in it called subfrmEpisode.
In that subfrmEpisode is another sub form called subfrmscore.

When I add a new patient, and start to add data in the subfrmepisode, the score in subfrmscore is supposed to update, but it doesn't unless you close and open the form. It does update if you go into an old record and change the data.

in AfterUpdate of subfrmEpisode I have

DoCmd.RefreshRecord

Why isn't this refreshing when I am adding a new record?
 
Make sure that relationship between the sub and sub-sub forms exists. Docmd refresh shouldn't be an issue here. Access automatically save an entry when the entry is completed.
 
The score relates to what? How is it calculated?

It won't update if the record hasn't yet been saved. If you add a new record, enter some data, move to an existing record and move back to the newly created record you will find that the score displays correctly.
 
have it working now!! BUT

It works fine on my Access 2010 but when trying it on Access 2003, I get a 'method or data not found' error message??
 
just out of interest vbaInet, I know it updates when you add a new record, but what about it appearing as your hit the save button???
I always advise user to hit the new record button just so that they can see that it does indeed display in the sub form, but it would be great if that happened as soon as they hit the save button.
 
just out of interest vbaInet, I know it updates when you add a new record, but what about it appearing as your hit the save button???
Yes, that would work too. If you put a Save button on the form it's good to ensure that it only becomes active when all the required fields have been filled in. So it obviously requires more coding which was why I didn't mention this.
 
it doesn't look like .refreshrecord existed in A2003

.refresh is supposed to refresh the screen of data, without requerying the whole dataset, but I have found odd cases in which it failed to work correctly.

you could try that - see if that works in A2010
 
...Why isn't this refreshing when I am adding a new record?
Because Refresh only reflects changes made to Existing Records! It does not show New Records nor Deleted Records. You have to actually Requery in order for that to happen.

Linq ;0)>
 
requery the calculated field should work
 
Yes, that would work too. If you put a Save button on the form it's good to ensure that it only becomes active when all the required fields have been filled in. So it obviously requires more coding which was why I didn't mention this.

The first field in subfrmepisode is Date referred. In that Lost focus property I have put

DoCmd.RunCommand acCmdSaveRecord

Also I have removed instances of DoCmd.Refresh and changed it to DoCmd.Requery

I am going to test it on Access 2003 to see if it works
 
The first field in subfrmepisode is Date referred. In that Lost focus property I have put

DoCmd.RunCommand acCmdSaveRecord
This is too much effort. You need to check that the data in that field was changed before you Save it.

Also, look into Me.Recalc (as missinglinq pointed out) to see whether it applies in your case.
 
This is too much effort. You need to check that the data in that field was changed before you Save it.

Also, look into Me.Recalc (as missinglinq pointed out) to see whether it applies in your case.


Good point about the save command. I have removed it.
I have put Me.Recalc in the forms 'On load' property. It works fine but when making changes to data, I have noticed the tab order jumps back to zero on the tab index every time a change is made
 
I didn't say you should remove. All I said was only save when data in that field is changed. There's an event for that.

Yet again I didn't say you should go ahead and use Me.Recalc. I just said you should research that method to see if it applies to you. Read the help files about it, look for some examples before using it.
 
I didn't say you should remove. All I said was only save when data in that field is changed. There's an event for that.

Yet again I didn't say you should go ahead and use Me.Recalc. I just said you should research that method to see if it applies to you. Read the help files about it, look for some examples before using it.

Ah I see

will look into the options vbainet as there seems to be more than one answer to this
 
will look into the options vbainet as there seems to be more than one answer to this
Correct! A few suggestions have been made. I would look into Me.Recalc and Me.Requery. By the way, the event I was referring to is the After Update event of the control.
 
As I understand it, the Recalc functions reevaluates calculated controls on the form.
The Requery method tells Access to go and re-fetch the data underlying the
query since something may have changed since it was last queried (or form
opened).
The score on my form is a subform with a query as its control source. It seems more appropriate to use Requery.
I had a problem when i was changing values in the form and the cursor would jump back to the 1st tab index when the requery has executed. I have used the setfocus function to fix this

Code:
Private Sub PastMedical_LVSD_Change()
DoCmd.Requery
PastMedical_LVSD.SetFocus
End Sub

Need to have a think about the 'save' bit in after update as I need to know if the user wants to have the power to save
(be prompted to save)
 
I had a problem when i was changing values in the form and the cursor would jump back to the 1st tab index when the requery has executed. I have used the setfocus function to fix this
When you requery the cursor jumps to the first record. That's normal behaviour

Code:
Private Sub PastMedical_LVSD_[COLOR=Red]Change()[/COLOR]
[COLOR=Red]DoCmd.Requery[/COLOR]
PastMedical_LVSD.SetFocus
End Sub[/QUOTE]Still pretty [COLOR=Red]heavy[/COLOR]. Save in the After Update event of the control, that's all you need.
 
When you requery the cursor jumps to the first record. That's normal behaviour

Still pretty heavy. Save in the After Update event of the control, that's all you need.


Yes i spotted that as well after abit of tinkering

I noticed - I could use the RefreshRecord function as well but for some reason its not working in Access 2003!!
Tried searhcing for a way to overcome this but to no avail

Requery works great but I have another form, and when I make updates to it, I am getting new records created when really I want to stick to the current record
 

Users who are viewing this thread

Back
Top Bottom