Hook up [Event Procedure] to control created via CreateControl() function

  • Thread starter Thread starter Ron Weiner
  • Start date Start date
R

Ron Weiner

I am building a form (DataSheet) that needs to morph to the number of fields
that the user has specified for a Test that they have devised elseware in
the app. I am good to go for getting the appropriate controls on the form
and getting them hooked to a temp datasource (which also gets created on the
fly). Everything works great, but I have now discovered that I need to do
some pretty hairy data validation which does not lend itself to using the
ValidationRule and ValidationText Properites of the controls I am creating.

What I would like to be able to do is to use some VBA under the BeforeUpdate
event that would set Cancel = true when the data does not validate. I am
good to go for the VBA code to make this happen, but I do not know how to
get this working. I have try'd setting the BeforeUpdate property of the
control to =MyValidateFunction(). The code in the function fires, but the
focus moves to the next control regardless of what the function returns
(True or False).

There has got to be a way, anyone done this before?

Ron W
 
If you set the BeforeUpdate property to a function, the property takes no
notice of the function's return value.

Instead:
DoCmd.CancelEvent
 
You Da' Man!

I am Good to go.

Thanks

Ron W
Allen Browne said:
If you set the BeforeUpdate property to a function, the property takes no
notice of the function's return value.

Instead:
DoCmd.CancelEvent
 
Back
Top