473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Creating a Module

I have code that is currently placed in the OnClose Event, and it's duplicated
in multiple forms, I would like to convert it to a module and call that module
instead of copy and pasting the code. Here is the code:

If IsNull(Forms!frm1!FormHolder) Then
DoCmd.OpenForm "Switchboard"
Else
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = Forms!frm1!FormHolder
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Thank you in advance for your assistance. Frm1 is open all the time in a Hidden
mode.

Michael
Nov 13 '05 #1
2 2009
Create a new Module and type enter the code below and save module. Then use
the OnClose event to call your module using "Call functionname()" (Be sure
to call the function name and not the name of the module that you saved.

Public Function functionname()
If IsNull(Forms!frm1!FormHolder) Then
DoCmd.OpenForm "Switchboard"
Else
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = Forms!frm1!FormHolder
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Function

"Lumpierbritches" <lu*************@aol.com> wrote in message
news:20***************************@mb-m11.aol.com...
I have code that is currently placed in the OnClose Event, and it's duplicated in multiple forms, I would like to convert it to a module and call that module instead of copy and pasting the code. Here is the code:

If IsNull(Forms!frm1!FormHolder) Then
DoCmd.OpenForm "Switchboard"
Else
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = Forms!frm1!FormHolder
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Thank you in advance for your assistance. Frm1 is open all the time in a Hidden mode.

Michael

Nov 13 '05 #2
You'll still need the onclose event of your form, just insted of the
below code in it, you'll just make a function call insted. Place the
below code in a function, in a module, and in the onclose event, just
call the function from your module just as you would call any other
function.

Also, I understand the variable defining, but it has always been my
own personal opinion that if you never use a variable, you can get rid
of it entirely (stLinkCriteria) and if you're only using it once, you
don't really need it either (stdocname). Defining two unnecessary
variables may not seem like a lot, but spread out over many forms used
repeatedly, it is a waste of memory. Getting rid of unnecessary
variables is an easy way to make your program run slightly faster and
use less memory. Again, just my personal opinion - take it however
you want.

lu*************@aol.com (Lumpierbritches) wrote in message news:<20***************************@mb-m11.aol.com>...
I have code that is currently placed in the OnClose Event, and it's duplicated
in multiple forms, I would like to convert it to a module and call that module
instead of copy and pasting the code. Here is the code:

If IsNull(Forms!frm1!FormHolder) Then
DoCmd.OpenForm "Switchboard"
Else
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = Forms!frm1!FormHolder
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Thank you in advance for your assistance. Frm1 is open all the time in a Hidden
mode.

Michael

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edvard Majakari | last post by:
Greetings, fellow Pythonistas! I'm about to create three modules. As an avid TDD fan I'd like to create typical 'use-cases' for each of these modules. One of them is rather large, and I wondered...
0
by: Angelos Karantzalis | last post by:
Hi y'all, only recently, I've delved into creating installers with VS.NET. So far, I'd created a Deployment Solution, added a couple of Merge Modules to it & everything worked fine. Today, I...
1
by: David Li | last post by:
I am having a lot of problem with following code. To start with I have a working sets of code and the top level SystemC code looks like this: ----------working main.cpp start here...
10
by: Java and Swing | last post by:
I need to write an extension for a C function so that I can call it from python. C code (myapp.c) ====== typedef unsigned long MY_LONG; char *DoStuff(char *input, MY_LONG *x) { ... } so...
0
by: James Fortune | last post by:
Here is an example of Access creating a single page PDF file. The text in the textbox is scaled to fit horizontally into a grey box 100 pixels wide that is fontsize pixels high. Clicking the...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
2
by: Edvard Majakari | last post by:
Hi, My idea is to create a system working as follows: each module knows path to plugin directory, and that directory contains modules which may add hooks to some points in the code. Inspired...
3
by: T | last post by:
I'm trying to determine the useage of varioius reports I have. I need the following to occur when a report is opened, get the name of the report, datetime, username. I created a tblLog...
0
by: mk189 | last post by:
Hi, I am trying to create XML schema of custom markup language, enriched by XHTML. In simplified version, the XML documet could look like that: <a:alarm-manual xmlns:a="alarm-manual"...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.