Re: Passing form name to generalized procedure

From: Brendan Reynolds (brenreyn)
Date: 02/24/05


Date: Thu, 24 Feb 2005 13:41:01 -0000

I'm assuming this is an Access form?

If so, an example would be ...

Public Sub TestFormRef(ByVal strFormName As String, ByVal strControlName As
String)

    Debug.Print Forms(strFormName).Controls(strControlName).Value

End Sub

Example of use in the Immediate window ...

testformref "frmTest","TestText"
My Test Text

BTW: This question doesn't seem to have much to do with ADO, and might have
been better asked in an Access newsgroup such as
microsoft.public.access.formscoding

-- 
Brendan Reynolds (Access MVP)
"Richard" <richard@discussions.microsoft.com> wrote in message 
news:06239396-DB72-4BDA-8CAA-B3F6A4610131@microsoft.com...
>I have a generalized procedure to process data entered into text boxes, for
> use with multiple forms.  The name of the current form is passed as a 
> String
> variable to the procedure.  When the procedure attempts to use the 
> variable
> to process a field ( i.e., Forms!frmNameVar(FieldName) ) an error message
> says that the module "can't find the form 'frmNameVar' referred to " in 
> the
> code.  If I substitute the actual name of the calling form into the VBA 
> code,
> the procedure works properly.
>
> How do I pass a form name to a generalized procedure and reference it to
> process text fields that are in the form?
>
> Richard 


Relevant Pages

  • Re: When and Why use "Me."?
    ... > Hi Richard, ... > In the example class below, Me is used to disambiguate between Sub New's ... > Public Property LastNameAs String ... > Public Sub ChangeLastName ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Passing form name to generalized procedure
    ... > Public Sub TestFormRef(ByVal strFormName As String, ... > Brendan Reynolds ... >> How do I pass a form name to a generalized procedure and reference it to ...
    (microsoft.public.data.ado)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: hyperlinks in a paragraph
    ... Public Sub Discover(ByVal MStr As String) ... Public Sub ProcPara ... Dim HL As Hyperlink ...
    (microsoft.public.word.vba.general)