Subform update - refresh

Sergio_Moreira

New member
Local time
Today, 01:03
Joined
Oct 14, 2015
Messages
5
Hi guys, hope you are all doing fine

Apologies for troubling you, but I guess I have to rely on your expertise to tackle one issue that is blocking me from progressing.

First of all, I’m an absolute rookie, but you would obviously figure that out on your own just by looking into my issue . Anyways, any ideas will be welcomed and highly appreciated.

Description:

I have a main form: [employee-area-pessoal]
Displaying 2 subforms:
[employee-area-pessoal-innerform-registo-horas-suplementos]
And
[employee-area-pessoal-subform-registo-horas-suplementos]

Actually both of these subforms have the exact same data source and field structure, they’re just there to display data in diferente layouts

The first subform is where all employees must record their work hours on a day-by-day basis, in form view, allowing add, edit, delete records
The second is just displaying all records already stored, but in datasheet view (gives a more accurate idea of the monthly records)

In the “data enter subform” ([employee-area-pessoal-innerform-registo-horas-suplementos]), I put a button right next to the last field that must be filled by the employee, that saves the record. But I just can’t get the datasheet subform to update immediately once a new record is saved – I can get it done with a refresh button on the main form, but I’d rather add this subform refresh as part of the save record event. Too newbie to figure it out how :banghead:

Funny thing is that editing data of na existing record instantaneously populates to the second subform, but not new records in it’s entirety.

Any ideas as how to do this guys?
Much obliged!
Kindest regards.
 
put the main form in design view click on the "data entry subform", on the Property->event->AfterUpdate:

Private Form_AfterUpdate()
Me.Parent!yourSecondSubformName.Form.Requery
End Sub

replace yourSecondSubformName with the correct name of your subform.
 
Thank you very much for your assistance.
But though I've written the code as you advised, once I run it, it stops. This is the error:

Afterupdate event on data entry form:

Private Sub Form_AfterUpdate ()
Me.Parent!employee-area-pessoal-subform-registo-horas-suplementos.Forms.Requery
End Sub

The error:

Compile Error:
Syntax error

Could you further assist please?
Kindest regards.
Sérgio
 
Put [] around the subform name. And do not use spaces, or - or any other non-alpha characters with the exception of _ in names in the future.
 
Thank you very much for your insights. I added the brackets surrounding the subform name, and eventually the errors stops. BUT: still the other subform is not refreshing data automatically.

Any other thoughts guys? Shall I change the form name to remove the "-"? Maybe this is what's confusing the code?

Much appreciated to you all.
Kindest regards.
 

Users who are viewing this thread

Back
Top Bottom