Full Version: Refresh sub subform
UtterAccess Forums > Microsoft® Access > Access Forms
melonheadmis
I have a form with a subform. On this subform are 4 tabs - all with another subform and these subforms may have subforms.
On one of these tabs, I have:
Subform titled Patient Procedure Form that has two subforms:
Patient Procedure Detail Form
Patient Procedure Datasheet '
The two subforms are the same information - just in different views.
Oenter the data on the Patient Procedure Detail Form and would like it to show up immediately on the datasheet. I can't get it to refresh unless I physically put my curser in a field in the datasheet and hit the refresh all main control.
I have tried adding various commands to after update on the Patient Procedure Detail Form the latest being:
Forms![Patient Procedure Detail Form].[Patient Procedure Datasheet].Form.Refresh
I've tried tons of the them however and haven't quite gotten them to work.
If you need the name of the other forms included:
FamilyNameForm
PatientNameForm
Then various tabs - one being the tab with the subforms listed above.
Thanks in advance!
Peter46
The first thing you have to do is save the record you are entering. Until you have done that it will not appear in the datasheet.
You can issue a refresh command from the afterupdate event procedure of the Detail form.
cycnus
The data you are editing in the Patient Procedure Detail Form will not be saved until you actually move away from that record, either by bringing the focus to another form or by moving record.
You could use the Patient Procedure Detail Form's OnTimer event and set its TimerInterval property to 1000 to ensure the form is always saved wtihin 1 second of being modified:
CODE
  Private Sub Form_Timer()
    If Me.IsDirty then
        Me.IsDirty=false
        Forms("Patient Procedure Datasheet").Refresh
    End If
  End Sub
melonheadmis
Thanks for the quick reply. I tried adding this to the Patient Procedure Datasheet Properties and adding the 1000 but then I would get a Visual Basic error message upon opening the main form or the subform that states, "Compile Error. Method or data member not found.
Any other suggestions?
melonheadmis
Peter46, Thanks also for the reply. The record is being saved however when I add a new. But the new ones don't show up in the datasheet. Not even when I have added multiple records. The only way they show up is after adding another record in the detail subform, I put my curser in the datasheet field and hit refresh.
melonheadmis
To add to my last post. They also show up when I got to a new record in the main form - the Family Form. But that is kind of annoying to have to do that everytime.
melonheadmis
Okay, my last post made me think of something. It's kind of a round about way, but I created a macro that would go the next record and then the previous record of the main form. I then made a macro to run the macro on the subform. You can see it thinking but at least it works.
However if there is another way, I would gladly welcome it!
cycnus
Hi,
You're supposed to add this to the OnTimer event of the "Patient Procedure Detail" form, not the Datasheet one.
Remove it from the datasheet form and don;t forget to set the Datasheet form's TimerInterval to 0.
Oalso mistyped the Dirty property (not IsDirty), actually, you should change it to:
CODE
  Private Sub Form_Timer()
    If Me.Dirty then
        Me.Dirty=false
        If CurrentProject.AllForms("Patient Procedure Datasheet").IsLoaded then
                Forms("Patient Procedure Datasheet").Refresh
        End If
    End If
  End Sub

Make sure the Patient Procedure Detail form has its TimerInterval set to 1000.
melonheadmis
That code made it closer but not quite. It did not change until I added another record to the subform Patient Procedure Form. (that both the Patient Procedure Datasheet and the Patient Procedure Detail Form are on.) Is there some code to add to refresh that record?
Thank you SO much for your help! It is really appreciated!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.