Re: CreateControl command Crashes Access



Owww! As Alan said, creating the controls at runtime aint the way to
go!

Your code looks pretty good, you've obviously written code before. I
think you've just got hung-up on createcontrol. You clearly have
sufficient coding skills to do it /without/ creating the buttons
through code.

Use Alan's idea to get a button per record. (Just have a button, along
with the fields, in the form that you put in a subform control.) That
button will only have s single Click event, even though there is a
physical instance of the button for each record in the subform. But
from that Click event, you can tell what record was actially clicked.

One problem there, is that you can't have a different caption on each
button. If you change the caption on "the" button (because there is
only one instance of the control that you can see *through code*), the
caption will change on *all* of the physical instances. So if you want
different captions, you'd have to use a textbox (instead of a button),
bind it to a function (which returns the text to display as the
caption), and use its format properties to make it look like a button.
Then you'd use the textbox'es Click event, to handle the clicks.

Hope that helps,

TC (MVP Access)
http://tc2.atspace.com

.