473,626 Members | 3,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assigning Openargs to a "Form" Variable!

Hi All,

I am using the code below to assign a form name to a form variable (vFrm).
Is there a way to assign the Openargs string directly to vFrm, i.e. vFrm =
Openargs ?

Private Sub Form_Load()
Public vFrm As Form

If Openargs = "subfrmProjects " then
vFrm = Form_subfrmProj ects
ElseIf Openargs = "frmProject s" Then
Set vFrm = Form_frmProject s
ElseIf Openargs = "frmCompone nts" Then
Set vFrm = Form_frmCompone nts
End If

End Sub

Thanks for your assistance,
Barry
Nov 13 '05 #1
4 7099
Barry Edmund Wright wrote:
Hi All,

I am using the code below to assign a form name to a form variable (vFrm).
Is there a way to assign the Openargs string directly to vFrm, i.e. vFrm =
Openargs ?

Private Sub Form_Load()
Public vFrm As Form

If Openargs = "subfrmProjects " then
vFrm = Form_subfrmProj ects
ElseIf Openargs = "frmProject s" Then
Set vFrm = Form_frmProject s
ElseIf Openargs = "frmCompone nts" Then
Set vFrm = Form_frmCompone nts
End If

End Sub


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could do something like this:

-- Declaration section

' Declare a module level variable to hold the name of the
' calling form.
Dim m_strCallingFor m As String

' An object reference variable that will hold the reference
' to the calling form object.
Dim m_frm As Form

Private Sub Form_Load()

m_strCallingFor m = Me.OpenArgs

End Sub

' Where you need to set a form object variable to the calling form
' do this.

Set m_frm = Forms(m_strCall ingForm)

This is what's known as "late binding." What you had been doing is
"early binding." Early binding is usually the preferred binding option
'cuz the compiler does all the binding of object methods/events before
the program runs. Late binding means the binding is done during the
program run and this can, possibly, slow down the processing. I've
found late binding to work well on most things I use it for. YMMV.
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQmPw+oechKq OuFEgEQLaKgCgnI 39gRGBttv+b5ZGJ m0383awyWgAnR2I
WuPYyljBBjrtcJd QCDxa/UJM
=G1Tc
-----END PGP SIGNATURE-----
Nov 13 '05 #2
MG, that worked like a charm! And thanks for taking the time to expain about
the late-binding thingy!

Best regards,
Barry

"MGFoster" <me@privacy.com > wrote in message
news:Qh******** **********@news read1.news.pas. earthlink.net.. .
Barry Edmund Wright wrote:
Hi All,

I am using the code below to assign a form name to a form variable
(vFrm).
Is there a way to assign the Openargs string directly to vFrm, i.e. vFrm
= Openargs ?

Private Sub Form_Load()
Public vFrm As Form

If Openargs = "subfrmProjects " then
vFrm = Form_subfrmProj ects
ElseIf Openargs = "frmProject s" Then
Set vFrm = Form_frmProject s
ElseIf Openargs = "frmCompone nts" Then
Set vFrm = Form_frmCompone nts
End If

End Sub


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could do something like this:

-- Declaration section

' Declare a module level variable to hold the name of the
' calling form.
Dim m_strCallingFor m As String

' An object reference variable that will hold the reference
' to the calling form object.
Dim m_frm As Form

Private Sub Form_Load()

m_strCallingFor m = Me.OpenArgs

End Sub

' Where you need to set a form object variable to the calling form
' do this.

Set m_frm = Forms(m_strCall ingForm)

This is what's known as "late binding." What you had been doing is
"early binding." Early binding is usually the preferred binding option
'cuz the compiler does all the binding of object methods/events before
the program runs. Late binding means the binding is done during the
program run and this can, possibly, slow down the processing. I've
found late binding to work well on most things I use it for. YMMV.
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQmPw+oechKq OuFEgEQLaKgCgnI 39gRGBttv+b5ZGJ m0383awyWgAnR2I
WuPYyljBBjrtcJd QCDxa/UJM
=G1Tc
-----END PGP SIGNATURE-----

Nov 13 '05 #3
Sorry MG, I hadn't cleared out some of the old code, so the module wasn't
using new code.

When I try to assign the global string:

Set m_frm = Forms(m_strCall ingForm)

I get run-time error '2450'
Database cannot find the form 'subfrmComp1' referred to in a macro
expression or Visual Basic code.

That's basically the problem I always get: I don't know how to assign a
"string" variable to a form using the Set statement.

Any thoughts on how to correct this error?
Thanks, Barry

"MGFoster" <me@privacy.com > wrote in message
news:Qh******** **********@news read1.news.pas. earthlink.net.. .
Barry Edmund Wright wrote:
Hi All,

I am using the code below to assign a form name to a form variable
(vFrm).
Is there a way to assign the Openargs string directly to vFrm, i.e. vFrm
= Openargs ?

Private Sub Form_Load()
Public vFrm As Form

If Openargs = "subfrmProjects " then
vFrm = Form_subfrmProj ects
ElseIf Openargs = "frmProject s" Then
Set vFrm = Form_frmProject s
ElseIf Openargs = "frmCompone nts" Then
Set vFrm = Form_frmCompone nts
End If

End Sub


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could do something like this:

-- Declaration section

' Declare a module level variable to hold the name of the
' calling form.
Dim m_strCallingFor m As String

' An object reference variable that will hold the reference
' to the calling form object.
Dim m_frm As Form

Private Sub Form_Load()

m_strCallingFor m = Me.OpenArgs

End Sub

' Where you need to set a form object variable to the calling form
' do this.

Set m_frm = Forms(m_strCall ingForm)

This is what's known as "late binding." What you had been doing is
"early binding." Early binding is usually the preferred binding option
'cuz the compiler does all the binding of object methods/events before
the program runs. Late binding means the binding is done during the
program run and this can, possibly, slow down the processing. I've
found late binding to work well on most things I use it for. YMMV.
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQmPw+oechKq OuFEgEQLaKgCgnI 39gRGBttv+b5ZGJ m0383awyWgAnR2I
WuPYyljBBjrtcJd QCDxa/UJM
=G1Tc
-----END PGP SIGNATURE-----

Nov 13 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

By the name of the form "subfrmComp 1" I'm guessing that the form is
being used as a subform, correct? If so, you can't use my example to
set the m_frm variable to the name of the form when it is a subform in
another form. To set a form reference variable to a subform you have to
indicate where that subform is (in which form). E.g.:

Set m_frm = Forms(m_strCall ingForm)!subFor mName.Form

If the subform is a subform of a subform (nested 2 deep):

Set m_frm = Forms(m_strCall ingForm)!subFor m1Name!subForm2 Name.Form

You can refer to subforms this way, too:

Set m_frm = Forms("form_nam e")("subform_na me").Form

So if you could pass the calling main form name and its subform name in
the OpenArgs parameter (and parse them out) you could use the above
example to set the m_frm variable.

See the Access VBA Help article "Form Object." Open the Debug window
[Ctrl+G] and type in Forms, put the cursor on the word Forms & hit the
F1 key. Then click on the Form bar (bottom blue bar in the diagram at
the top of the Help page). At the bottom of the "Form Object" Help page
is a discussion of subforms & how to refer to them using VBA.
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQmUvaIechKq OuFEgEQIw8gCg8E FBZFNKM16J5uGsX x4gzLL1mvUAn0j/
7WX8YL2ld9CIfSB 75/OOOVZv
=1xhm
-----END PGP SIGNATURE-----

Barry Edmund Wright wrote:
Sorry MG, I hadn't cleared out some of the old code, so the module wasn't
using new code.

When I try to assign the global string:

Set m_frm = Forms(m_strCall ingForm)

I get run-time error '2450'
Database cannot find the form 'subfrmComp1' referred to in a macro
expression or Visual Basic code.

That's basically the problem I always get: I don't know how to assign a
"string" variable to a form using the Set statement.

Any thoughts on how to correct this error?
Thanks, Barry

"MGFoster" <me@privacy.com > wrote in message
news:Qh******** **********@news read1.news.pas. earthlink.net.. .
Barry Edmund Wright wrote:
Hi All,

I am using the code below to assign a form name to a form variable
(vFrm).
Is there a way to assign the Openargs string directly to vFrm, i.e. vFrm
= Openargs ?

Private Sub Form_Load()
Public vFrm As Form

If Openargs = "subfrmProjects " then
vFrm = Form_subfrmProj ects
ElseIf Openargs = "frmProject s" Then
Set vFrm = Form_frmProject s
ElseIf Openargs = "frmCompone nts" Then
Set vFrm = Form_frmCompone nts
End If

End Sub


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could do something like this:

-- Declaration section

' Declare a module level variable to hold the name of the
' calling form.
Dim m_strCallingFor m As String

' An object reference variable that will hold the reference
' to the calling form object.
Dim m_frm As Form

Private Sub Form_Load()

m_strCallingFor m = Me.OpenArgs

End Sub

' Where you need to set a form object variable to the calling form
' do this.

Set m_frm = Forms(m_strCall ingForm)

This is what's known as "late binding." What you had been doing is
"early binding." Early binding is usually the preferred binding option
'cuz the compiler does all the binding of object methods/events before
the program runs. Late binding means the binding is done during the
program run and this can, possibly, slow down the processing. I've
found late binding to work well on most things I use it for. YMMV.
--
MGFoster:::mg f00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQmPw+oechKq OuFEgEQLaKgCgnI 39gRGBttv+b5ZGJ m0383awyWgAnR2I
WuPYyljBBjrtc JdQCDxa/UJM
=G1Tc
-----END PGP SIGNATURE-----


Nov 13 '05 #5

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

Similar topics

3
2688
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their "name" property (which sources from "name" HTML attribue). The problem is, that if the form contains form control named "name", it overwrites the form name property. In fact, I'm quite surprised that it's so easy to spoil any of the form object...
2
3863
by: Barry Edmund Wright | last post by:
Hi, I want to use some generic code to assign a Form variable "vFrm" a value. My basic question is: is there some internal Access function that can return the fully qualified name of the Application.CurrentObjectName, i.e., "Form_frmHRName" instead of just "frmHRName" so it can be assigned to a form variable: dim vFrm as Form vFrm = "What should the code be here"
3
3389
by: IMRAN SAROIA | last post by:
Hi, I am passing file through aspSmartUpload by using input file form control in my form. But I cannot use Request.Form("Variable") command in my called asp. And it says you cannot use it during or after binary read. I guess aspsmartupload my have resolution for its problem. Please advise resolution.
8
2040
by: Martin | last post by:
I hope not, but, I think the answer to this question is "it can't be done". Northwind sample database. Orders form. Go to a new record. Select a customer in "Bill To:" Don't enter any products whatsoever. Now click or page up/down away from this new record. You just created a new order without a single item having been ordered. Not something a user should be able to do.
0
3141
by: hellind | last post by:
When the form is submitted as ENCTYPE="multipart/form-data" using AspUpload component, I understand to use Upload.form("") to retreive the form elements. But I cannot retreive it from inside a class. Anybody can help? The form page goes to upload.asp, where inside upload.asp it calls the class which reads the form element and return back the values. Here is the code of the class. Class pluginFileTransfer Public path,...
3
1974
by: G | last post by:
Hello, I have a c# ASPX file, and a Code Behind file. This file has contents POSTED to it, around 15 form fields. Rather than manually catch each Request.Form - is there an easy way to simply create a loop which does the following: 1: Look for ALL posted form fields
9
2380
by: Anil Gupte | last post by:
I have a MDI Parent Child set of forms FormContainer --MDIParent FormStart --MDIChild FormMain-->MDIChild FormSliceInfo-->MDIChild I use the following in the beginning of FomrContainer Public Class FormContainer Inherits System.Windows.Forms.Form
1
1797
by: chas2007 | last post by:
I need to pass a variable from a php function to a form. Does anyone have an example of code that would do this? Below is the code. I need to pass the "return value" from the php function mem_cost to the "amount" listed in the "form" <?php function mem_cost() { $w_month = strftime("%m"); if (($w_month >= "01") && ($w_month <= "06"))
3
1900
by: eBob.com | last post by:
How does a "sub-form", i.e. one invoked by another form, determine anything about the form which brought it into existence, i.e., I suppose, instantiated it? I wanted to so something like this ... MsgBox("called by " & Owner.Name) .... but that throws a null reference exception. Parent.Name and ParentForm.Name also throw null reference exceptions. Form1.Name works - but that's not very flexible.
0
8272
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8205
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8713
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8644
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8514
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.