Adding OnLoad event in code

G

Gert de Boom

I'm using Access Automation from Delphi. I have to change a lot of
Access Forms (about 200) and add some code in the Form_Load.

The changes I'm making is for making the application multi language. I
have to replace captions and stringconstants by variable (depending on
the active langauge) captions and strings that get their values from a
database table.

Making the necessary changes manually is a tough job, so I generate
most of the changes (CommandButton.Caption/Label.Caption/MsgBox
strings). The only thing to be done for these controls is the
translation of the words in the table.

This is how I do it

First I save an ASCII dump of the Form by using SaveAsText
(undocumented). Then I parse the file for the changes to be made and
make the appropriate changes. After that the Form is reloaded into
Access by using LoadFromText.

If the OnLoad=[Event Procedure] is already assigned this approach
works. If the OnLoad assignment is missing I tried adding it to the
ASCII dump too. Then the import fails. The error I get: "Property not
found" (or sometimes "The Server throw an exception").

After manually adding an [Event Procedure] to the OnLoad property in
Access and then making the same changes importing works.

The only differences I see in the ASCII dumps is in the GUID's and the
NameMap part. Changing the GUID's to other values and then importing
works ok. So the problem probably is the NamePart section. What does
this do ? How do I change it to reflect adding an OnLoad event ?

I've already tried to set the OnLoad property of the Access Form in my
Delphi application (before the SaveAsText call) but this doesn't work
because the OnLoad property is not supported from Automation.

Anyone who can give me any hints about how to add an OnLoad event and
procedure ? Or how I can change (generate) the NameMap so it will be
imported correctly ?

Thanks in advance
Gert de Boom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top