By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

Replace one section of code instead of replacing the whole form

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Cool - I'll give that a shot.

Nov 13 '05 #5

P: n/a
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

P: n/a
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

P: n/a
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.