472,980 Members | 2,022 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Cannot use a standard module

Hello--I have the code below attached to a command button--it opens an
error log form:

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = Me!RecID
Forms!reporterror!PatientID = Me!PatId
End Sub

I want to use this on many forms but cannot use a standard module
without referencing the form I am pulling the value from--which
defeats my purpose. Is there any other way to use this code in
multiple places?

thanks
bob
Nov 13 '05 #1
7 1918
Yes, you can move the code to a stadnare module. The code will look like:
dim frmMe as form

set frmMe = screen.ActiveForm

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = frmMe!RecID
Forms!reporterror!PatientID = frmMe!PatId
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #2
Thank you very much! Works just fine!!
On Tue, 22 Mar 2005 21:43:46 GMT, "Albert D. Kallal" <ka****@msn.com>
wrote:
Yes, you can move the code to a stadnare module. The code will look like:
dim frmMe as form

set frmMe = screen.ActiveForm

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = frmMe!RecID
Forms!reporterror!PatientID = frmMe!PatId


Nov 13 '05 #3
And as long as I am asking--can I pull the originating form name into
a field on the error form also?

thanks
On Tue, 22 Mar 2005 15:00:36 -0700, al*****@cox.net wrote:
Thank you very much! Works just fine!!
On Tue, 22 Mar 2005 21:43:46 GMT, "Albert D. Kallal" <ka****@msn.com>
wrote:
Yes, you can move the code to a stadnare module. The code will look like:
dim frmMe as form

set frmMe = screen.ActiveForm

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = frmMe!RecID
Forms!reporterror!PatientID = frmMe!PatId


Nov 13 '05 #4
frmMe.Name

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

<al*****@cox.net> wrote in message
news:6e********************************@4ax.com...
And as long as I am asking--can I pull the originating form name into
a field on the error form also?

thanks
On Tue, 22 Mar 2005 15:00:36 -0700, al*****@cox.net wrote:
Thank you very much! Works just fine!!
On Tue, 22 Mar 2005 21:43:46 GMT, "Albert D. Kallal" <ka****@msn.com>
wrote:
Yes, you can move the code to a stadnare module. The code will look like:
dim frmMe as form

set frmMe = screen.ActiveForm

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = frmMe!RecID
Forms!reporterror!PatientID = frmMe!PatId

Nov 13 '05 #5
"Albert D. Kallal" <ka****@msn.com> wrote in
news:mk00e.759333$6l.335837@pd7tw2no:
Yes, you can move the code to a stadnare module. The code will
look like:
dim frmMe as form

set frmMe = screen.ActiveForm

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = frmMe!RecID
Forms!reporterror!PatientID = frmMe!PatId


Why not make the form name an argument passed to the subroutine?

Public Sub OpenErrorForm(frm As Form)
DoCmd.OpenForm "ReportError"
With Forms!ReportError
!RecordID = frm!RecID
!PatientID = frm!PatId
End With
End Sub

You'd use it like this:

Call OpenErrorForm (Me)

OR

OpenErrorForm Me

By passing the form, you don't have to worry about assigning the
variable and you get the benefit of calling it for something other
than the currently active form (should you ever need to).

I also have never trusted .ActiveForm, as it depends on events in
the UI. Passing the exact form reference seems to me to be the most
robust way of doing this, rather than depending on a 2nd-hand method
of finding out which form it is.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.78...
By passing the form, you don't have to worry about assigning the
variable and you get the benefit of calling it for something other
than the currently active form (should you ever need to).

Yes, the above is a fair point.

I also have never trusted .ActiveForm, as it depends on events in
the UI. Passing the exact form reference seems to me to be the most
robust way of doing this, rather than depending on a 2nd-hand method
of finding out which form it is.


The above has never been a problem Remember, when you start using a LOT of
custom menu bars etc, then your code OFTEN has to rely the screen object.
Further, this approach also means that ones custom menu bars/code will
operation on any active form. And, no matter what code calls the routine..it
will work, and those calling routines don't have to care/worry about passing
the form object. (so, there is some pros/cons here!).

So, I 100% agree, for most code, I would in fact pass the form object.
However, for menu bar code..and "general" routines (that menus + tool bars
force you to write!!), then using the screen object is standard fair, and is
reliable. The end result is more general code. You do as a rule need to
pick up the screen object RIGHT AT the start of the code, since any focus
change could have disaster results. However, once you pick up the screen
object, then a focus change does not cause a problem. Ones mileage will
certainly vary on this...especially if one is not a big user of menu bars
(which I am!).

In applications built around custom menus......often the screen object is
the only reasonable approach.

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #7
Thanks to David and Albert--I have a need for this module in many
different areas of projects I am working on and this will save me lots
of time! Now to figure out loops!
On Wed, 23 Mar 2005 00:55:38 GMT, "David W. Fenton"
<dX********@bway.net.invalid> wrote:
"Albert D. Kallal" <ka****@msn.com> wrote in
news:mk00e.759333$6l.335837@pd7tw2no:
Yes, you can move the code to a stadnare module. The code will
look like:
dim frmMe as form

set frmMe = screen.ActiveForm

DoCmd.OpenForm "ReportError"
Forms!reporterror!RecordID = frmMe!RecID
Forms!reporterror!PatientID = frmMe!PatId


Why not make the form name an argument passed to the subroutine?

Public Sub OpenErrorForm(frm As Form)
DoCmd.OpenForm "ReportError"
With Forms!ReportError
!RecordID = frm!RecID
!PatientID = frm!PatId
End With
End Sub

You'd use it like this:

Call OpenErrorForm (Me)

OR

OpenErrorForm Me

By passing the form, you don't have to worry about assigning the
variable and you get the benefit of calling it for something other
than the currently active form (should you ever need to).

I also have never trusted .ActiveForm, as it depends on events in
the UI. Passing the exact form reference seems to me to be the most
robust way of doing this, rather than depending on a 2nd-hand method
of finding out which form it is.


Nov 13 '05 #8

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

Similar topics

5
by: Robin Cull | last post by:
Hi all, I'm writing a script that needs to do lookups on the UNIX passwd and groups file on textual usernames/group names and return numeric UID/GID. Something that gives access to the C...
5
by: sdhyok | last post by:
Here is my situation. To add more functionalities to a standard library(datetime) in python, I am implementing my own code called vp.datetime (directory structure, vp/datetime.py). To make it...
3
by: Laax | last post by:
Hi, I am trying to compile a .cc file and get the following error. I have translated the error message from original japanese text. So, it may not look exactly like standard(English) error...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
8
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
3
by: David T. Ashley | last post by:
Hi, Red Hat Enterprise Linux 4.X. I'm writing command-line PHP scripts for the first time. I get the messages below. What do they mean? Are these operating system library modules, or...
21
by: Cottonwood | last post by:
I want to call a C module from a Fortran program. Whatever I tried - the linker could not find the C module. I know about the leading underscore and switched even that off. I abstracted everything...
2
by: Chris Miles | last post by:
On a standard Solaris 10 installation with Sun-supplied open-source packages installed (like SFWrline for readline libs) I cannot seem to force Python configure/setup.py to build with readline...
1
by: kw.housing | last post by:
I have all the library already in path: $ ls -l /opt/IBM/db2/lib64 | grep libdb2o -r-xr-xr-x 1 bin bin 7757295 Jul 12 2006 libdb2osse.a* -r--r--r-- 1 bin bin ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.