Results 1 to 2 of 2
Thread: Variable to get Form Name (XP )
2003-02-05, 09:08 #1
- 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
2003-02-05, 09:39 #2
- 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")