Module or Class Module

F

Falty

I have a database which is for call logging for the IT dept, there is one
form for entering the call and this form is duplicated 8 times, one for each
of the sites that we manage. It all works fine except there is a fair bit of
visual basic code which is then duplicated 8 times and it slows down the
whole database. Is there a way of writing the code once and having an active
form call on the code when required. I tried writing it into a module but it
does not like the keyword Me and if i type into into a class module it does
not recognise the sub at all. When i wrote the code into the Module and Class
module it was just an exact copy of the code from the form. Is there an
easier way? Do i have to change the code or have i done something wrong?
 
B

Brendan Reynolds

You will need to make some modifications to the code, yes.

For example, suppose you have some code behind a form that looks like this
....

Me!SomeTextBox = SomeValue

There are at least three different ways that you could re-write this code so
that it will work in a public procedure in a standard module. You could pass
the name of the form as an argument to the procedure ...

Public Sub SomeSub(NameOfForm As String)
Forms(NameOfForm)!SomeTextBox = SomeValue
End Sub

.... or you could pass the form as an object ...

Public Sub SomeSub(TheForm As Form)
TheForm.Controls("SomeTextBox") = SomeValue
End Sub

.... or you could pass the text box as an object ...

Public Sub SomeSub(TheTextBox As TextBox)
TheTextBox = SomeValue
End Sub
 
F

Falty

Thank you very much for your help it worked great, i used the first option
"as String". The only problem being that this has now slowed down load time
of the database even more, when i thought it would speed it up??? The file
size is even larger as well. i would have thought it would be smaller with
all of the code removed from the individual pges. Do you have any ideas on
how to make it load faster???

Each tab on the page( 8 in total 1 for each site) is set top run on current
event.
There is also a timer event on each tab to keep it up to date with elapsed
time
 
J

Jesper

Thank you very much for your help it worked great, i used the first option
"as String". The only problem being that this has now slowed down load
time
of the database even more, when i thought it would speed it up???

I assume you've compiled, compacted and repaired?

Jesper
 

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