Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Thanked 0 Times in 0 Posts

    Variable to get Form Name (XP )

    In order to capture the name of the screen from which a function is called, I create a variable called CALLSCREEN (original, huh?).

    In an attempt to capture the contactID of the calling screen, I use the code:
    nc = "[Forms]!" & callscreen & ".[ContactID]"

    All is fine, if I call the function from the 'Phone' screen then nc ="[Forms]!Phone.[ContactID]"

    Wonderful - except that now I want the integer variable FN to grab the actual contactID number, so that FN will return 23 or 342 or whatever the contactid of the calling form is. Problem.

    I have tried things like fn = Right(Left(nc, Len(nc) - 1), Len(nc) -2)
    fn = Val(nc)
    but nothing works. How can I do this?

    Thanks in advance

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Variable to get Form Name (XP )

    Your nc is just a string, not an object. Instead, try

    fn = Forms(callscreen).Controls("ContactID")

    Note: CodeContextObject is a property that represents the object (form, report) that is running the code. So you can also use

    fn = CodeContextObject.Controls("ContactID")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts