469,626 Members | 1,167 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Replace one section of code instead of replacing the whole form

Instead of sending an entire form to a client that includes code changes,
I'm trying to update just one section of code.

If I know the object, function name & property, is there a way to search
that function, and replace the current function's info with new function
info?

Example of what I need...
(1) Open the "frmClients" form in design view. (I can do already).
(2) Find the code behind the OnClick property of btnPrintHistory.
(3) Replace the OnClick property code of btnPrintHistory with a different
piece of code, stored in c:\NewCode.txt.
(4) Save & close the form. (I can do already)

History: I've created other functions to replace the entire form (sending
the whole form in an "update database" file, automating the renaming of
the original form then importing the new form). But, I've taught some
clients how to add buttons and fields. If I replaced the entire form,
their own changes are gone, so I'd like to try to figure out a way to
change the code of one button as described above.

Thx in advance!

Nov 13 '05 #1
7 1428
Access2003Guru wrote:
Instead of sending an entire form to a client that includes code changes,
I'm trying to update just one section of code.

If I know the object, function name & property, is there a way to search
that function, and replace the current function's info with new function
info?

Example of what I need...
(1) Open the "frmClients" form in design view. (I can do already).
You must open the code module here before you can do (2) See
docmd.openmodule. (As of A97, that is)
(2) Find the code behind the OnClick property of btnPrintHistory.


dim M as module
docmd.openmodule "form_frmClients"
set m=modules("Form_frmClients")
now, check what you can do with M. Intellisense should point you out; be
sure to read all documentation you have.

If you wind up having more questions now than answers, that's good for
now. I hope Help is available to you; otherwise I'd be happy to chunk in
my results (with A97, again)

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
Sorry that this doesn't really answer your question directly, but do you
split out your databases? That way all the important data is in one mdb and
the code, queries and macros are in another mdb that you update from time to
time.

Scott

"Access2003Guru" <ac************@hotmail.com> wrote in message
news:ed******************************@localhost.ta lkaboutdatabases.com...
Instead of sending an entire form to a client that includes code changes,
I'm trying to update just one section of code.

If I know the object, function name & property, is there a way to search
that function, and replace the current function's info with new function
info?

Example of what I need...
(1) Open the "frmClients" form in design view. (I can do already).
(2) Find the code behind the OnClick property of btnPrintHistory.
(3) Replace the OnClick property code of btnPrintHistory with a different
piece of code, stored in c:\NewCode.txt.
(4) Save & close the form. (I can do already)

History: I've created other functions to replace the entire form (sending
the whole form in an "update database" file, automating the renaming of
the original form then importing the new form). But, I've taught some
clients how to add buttons and fields. If I replaced the entire form,
their own changes are gone, so I'd like to try to figure out a way to
change the code of one button as described above.

Thx in advance!

Nov 13 '05 #3
This KB article on how to use code to write code might be helpful:

http://support.microsoft.com/default...b;en-us;208793

"Access2003Guru" <ac************@hotmail.com> wrote in message
news:ed******************************@localhost.ta lkaboutdatabases.com...
Instead of sending an entire form to a client that includes code changes,
I'm trying to update just one section of code.

If I know the object, function name & property, is there a way to search
that function, and replace the current function's info with new function
info?

Example of what I need...
(1) Open the "frmClients" form in design view. (I can do already).
(2) Find the code behind the OnClick property of btnPrintHistory.
(3) Replace the OnClick property code of btnPrintHistory with a different
piece of code, stored in c:\NewCode.txt.
(4) Save & close the form. (I can do already)

History: I've created other functions to replace the entire form (sending
the whole form in an "update database" file, automating the renaming of
the original form then importing the new form). But, I've taught some
clients how to add buttons and fields. If I replaced the entire form,
their own changes are gone, so I'd like to try to figure out a way to
change the code of one button as described above.

Thx in advance!

Nov 13 '05 #4
Cool - I'll give that a shot.

Nov 13 '05 #5
Yes - the databases are already split. I'm just needing to modify code of
one button property in the front-end db and send it to the person with the
live database without affecting any other part of that form.

Nov 13 '05 #6
I'll take a look at that. At first glance, it looks like it is just
modifying a module object and not others (i.e. a form), but it's
definitely a step in the right direction. Thx!

Nov 13 '05 #7
I've only used this for standard modules, but I believe you can use it for a
form's module by referring to the module this way:

Forms![MyForm].Module

and then using the module's methods and properties as the article describes.

"Access2003Guru" <ac************@hotmail.com> wrote in message
news:7b******************************@localhost.ta lkaboutdatabases.com...
I'll take a look at that. At first glance, it looks like it is just
modifying a module object and not others (i.e. a form), but it's
definitely a step in the right direction. Thx!

Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Brian | last post: by
4 posts views Thread by Locusta | last post: by
3 posts views Thread by Andy Sutorius | last post: by
5 posts views Thread by djc | last post: by
23 posts views Thread by digitalorganics | last post: by
4 posts views Thread by SirCodesALot | last post: by
6 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
5 posts views Thread by shapper | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.