PDA

View Full Version : Solved: Form_Current not called the 1rst time when there's no records



snorkyller
02-18-2011, 08:56 AM
I have a bug that I can't resolve.
It happens when I Requery a subform for the first time after I opened the form, and only if there are no records.
The bug is that the Form_Current event is not called (I'm talking about the Form_Current event of the Form displayed in the subform).

More precisely:
When I choose a Client, the Contracts related to this Client are displayed into a subform. If the Client doesn't have any Contract yet, than the Form_Current event will not be called. But if I select a 2nd time this Client, the subform will be Requery for a 2nd time, and then the Form_Current event will be called (???).
When I choose a Client that has many Contracts, everything's right.

Here's how I requery the subform:
[Forms]![frmGestionClients]![sfrSuivis].Requery

I hope that you have a clue... This is very strange.

SoftwareMatt
02-18-2011, 09:12 AM
Where do you call the requery line from and when?

have you got it on the AfterUpdate of the Client field on the main form?
If no then you should and I woul write it like this:

Me!sfrSuivis.Form.Requery

If you want to requery from another form use this:
[Forms]![frmGestionClients].[Form]![sfrSuivis].Requery

snorkyller
02-18-2011, 09:21 AM
Thanks anyway SoftwareMatt ;)

For those who would have the same problem, here's the solution:

It's a very stupid behavior of access.

If the AllowAdditions property of your main form is set to false, than the AllowAdditions property of the sub form will be automatically set to false when the main form will be load, even if you have set it to true.
And, when AllowAdditions = False, the Form_Current event isn't called.