Using Access 97 SR-2 with Windows XP.
I have form with a BeforeUpdate event which checks a true/false condition of the record being updated. When the user moves to the next record or leaves the form and the condition is true, then a msgbox asks if the user has saved the record. If the user clicks "No", then the form cancels any movement and remains at the same record so the user can then save.
This works absolutely fine when I use a private sub for the BeforeUpdate event. The problem I'm having is that I have several forms that all do the same check, and to avoid replication of code, I've created a module instead, however, the cancel doesn't work when I do it by module. Every other part of the code seems to go through ok, question, etc, but the form still moves onto the next selected record (or close if that is what the user is doing).
The only difference I can see to doing it both ways, and I'm sure this is something that I'm missing due to a lack of proper training on my part, is that the first line of the private sub is...
And the first line of the module is...
With "Cancel As Integer" being declared as a public variable.
I can post all code if required, but if anyone knows straight away what the difference is, I'd really appreciate it.
thanks...
I have form with a BeforeUpdate event which checks a true/false condition of the record being updated. When the user moves to the next record or leaves the form and the condition is true, then a msgbox asks if the user has saved the record. If the user clicks "No", then the form cancels any movement and remains at the same record so the user can then save.
This works absolutely fine when I use a private sub for the BeforeUpdate event. The problem I'm having is that I have several forms that all do the same check, and to avoid replication of code, I've created a module instead, however, the cancel doesn't work when I do it by module. Every other part of the code seems to go through ok, question, etc, but the form still moves onto the next selected record (or close if that is what the user is doing).
The only difference I can see to doing it both ways, and I'm sure this is something that I'm missing due to a lack of proper training on my part, is that the first line of the private sub is...
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Code:
Public Function BeforeUpdateRecord()
I can post all code if required, but if anyone knows straight away what the difference is, I'd really appreciate it.
thanks...
Comment