Which event you choose to use depends on when you want the action to execute.
OnCreate
executes once only during the lifetime of the form.
OnShow
executes every time the form goes from hidden to showing. Potentially it can execute many times during the lifetime of the form.
OnActivate
executes every time the form form receives focus. Potentially it can execute many times during the lifetime of the form.
The controls that are defined in the .dfm file are all instantiated by the time each of these events fires.
So, on the face of it, of these choices, OnCreate
is probably the most logical choice for initialization code. But only you can know for sure when you want this code to run.
As for the exceptions that you encounter, they are because your code contains bugs. Since we cannot see your code, you'll need to debug the code without our help.