p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: string expression


Message #1 by "Howard Stone" <ququmber@h...> on Fri, 21 Jun 2002 19:25:03
I have a form with a subform.  The main form is called frmCompanyExpense 
and the subform is named frmExpenseDetails. I am writing codes and 
constantly referencing the subfrom and its controls using:

Forms!frmCompanyExpense!frmExpenseDetails!SubformControl

I want to cut down on my typing and use a short String to replace Forms!
frmCompanyExpense!frmExpenseDetails!.  I tried by declaring it as string 
and as Form but it does not work.

How should I declare a short variable to carry the expression:
Forms!frmCompanyExpense!frmExpenseDetails! and cut down on my typing?

Thanks

Message #2 by "Joe Black" <elbeanburrito@h...> on Fri, 21 Jun 2002 15:14:09 -0400
if i understand what you are asking you can do

with frmExpenseDetails.ControlNameHere
       xxxx.xxxx = .caption
end with

example you want to get info from a listbox and continue working with it
and input data to existing labels on your main form

with frmExpenseDetails.List1
    label1.caption=.list(1)
    label2.caption=.list(2)
    .list clear
end with

HTH

Norm


>From: "Howard Stone" <ququmber@h...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] string expression
>Date: Fri, 21 Jun 2002 19:25:03
>
>I have a form with a subform.  The main form is called frmCompanyExpense
>and the subform is named frmExpenseDetails. I am writing codes and
>constantly referencing the subfrom and its controls using:
>
>Forms!frmCompanyExpense!frmExpenseDetails!SubformControl
>
>I want to cut down on my typing and use a short String to replace Forms!
>frmCompanyExpense!frmExpenseDetails!.  I tried by declaring it as string
>and as Form but it does not work.
>
>How should I declare a short variable to carry the expression:
>Forms!frmCompanyExpense!frmExpenseDetails! and cut down on my typing?
>
>Thanks
>




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Message #3 by "David Chapman" <luckychap@b...> on Sat, 22 Jun 2002 05:39:57 +0930
Dim F as form
use .form to denote a control on a subform as distinct from the subform
itself.
set  F = Forms![frmCompanyExpense]![frmExpenseDetails].form!SubformControl
The square brackets may not be necessary - they are a compolsive hang over
from Access v2
David

-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Friday, June 21, 2002 7:25 PM
To: Access
Subject: [access] string expression


I have a form with a subform.  The main form is called frmCompanyExpense
and the subform is named frmExpenseDetails. I am writing codes and
constantly referencing the subfrom and its controls using:

Forms!frmCompanyExpense!frmExpenseDetails!SubformControl

I want to cut down on my typing and use a short String to replace Forms!
frmCompanyExpense!frmExpenseDetails!.  I tried by declaring it as string
and as Form but it does not work.

How should I declare a short variable to carry the expression:
Forms!frmCompanyExpense!frmExpenseDetails! and cut down on my typing?

Thanks


Message #4 by "Kenny Alligood" <kennyalligood@h...> on Sat, 22 Jun 2002 11:01:02 -0400
------=_NextPart_001_0000_01C219DC.190913C0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Try:

Dim strForm as String

strForm =3D "frmCompanyExpense!frmExpenseDetails"

Then just refer to the form as strForm in your code.

Kenny

----- Original Message -----
From: Howard Stone
Sent: Friday, June 21, 2002 2:16 PM
To: Access
Subject: [access] string expression

I have a form with a subform.  The main form is called frmCompanyExpense
and the subform is named frmExpenseDetails. I am writing codes and
constantly referencing the subfrom and its controls using:

Forms!frmCompanyExpense!frmExpenseDetails!SubformControl

I want to cut down on my typing and use a short String to replace Forms!
frmCompanyExpense!frmExpenseDetails!.  I tried by declaring it as string
and as Form but it does not work.

How should I declare a short variable to carry the expression:
Forms!frmCompanyExpense!frmExpenseDetails! and cut down on my typing?

Thanks

to unsubscribe send a blank email to G
et more from the Web.  FREE MSN Explorer download : http://explorer.msn.c
om

Message #5 by "Amy Wyatt" <amyw@c...> on Mon, 24 Jun 2002 13:50:11
Having had lots of experience with this (I have a main form that contains 
over 10 subforms) I found it easiest to define a variable as a Form and 
set it equal to the subform as David suggested. However, this is the 
syntax I had to use to get it to work, (believe me, I tried everything).

Dim frmSub as Form

Set frmSub=Forms!frmCompanyExpense.Form!frmExpenseDetails.Form

from here you can then use frmSub!txtTextBox (or what ever the control 
name is) to get the control's information.

If you set this up as a Global variable, you can then define it on opening 
the main form and leave it defined until you close the main form.

Good luck,

Amy

> Dim F as form
use .form to denote a control on a subform as distinct from the subform
itself.
set  F = Forms![frmCompanyExpense]![frmExpenseDetails].form!SubformControl
The square brackets may not be necessary - they are a compolsive hang over
from Access v2
David

-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Friday, June 21, 2002 7:25 PM
To: Access
Subject: [access] string expression


I have a form with a subform.  The main form is called frmCompanyExpense
and the subform is named frmExpenseDetails. I am writing codes and
constantly referencing the subfrom and its controls using:

Forms!frmCompanyExpense!frmExpenseDetails!SubformControl

I want to cut down on my typing and use a short String to replace Forms!
frmCompanyExpense!frmExpenseDetails!.  I tried by declaring it as string
and as Form but it does not work.

How should I declare a short variable to carry the expression:
Forms!frmCompanyExpense!frmExpenseDetails! and cut down on my typing?

Thanks



  Return to Index