Full Version: Expression value and the string value of itself
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
brandon000
Buddy ol' Pals...I need your help again.

I'm not sure if this is possible but here it goes.

In visual basic I want to do this:

Form 1 Code
---------------
DoCmd.OpenForm "Form 2", , , , , , Forms![Purchase Orders]![Status]


Form 2 Code
---------------
When the form opens to say:

Message 1 = "The value of Status is Yes or -1"
Message 2 = "The string used to calculate is Forms![Purchase Orders]![Status]"


Is it possible to do this with just the OpenArgument of Form 1 and somehow converting it so that it knows to give both the value and it's actual string expression of itself?

Please tell me it's possible :-)




Edited by: brandon000 on Sat Jan 27 20:05:17 EST 2007.
John Vinson
It's not quite clear what you're trying to do - but I'd suggest passing the expression *as a string* in the OpenArgs parameter of OpenForm, and then using Eval() to determine the value of that string.
Alan_G
What is the actual value of Forms![Purchase Orders]![Status] that you're passing to Form 2, and what does it represent? How is the value of Status on Form 2 being determined to be Yes..?

Need a bit more info on what you're trying to do.............
LPurvis
Agreeing with the above - but with a slight venture as to why you're wanting to do that...

You want the value of the control passed - but perhaps also to know which form and control was responsible for passing that to the form (as more than one place might initiate launching the form in that manner).

Passing a string of the expression and evaluating it is certainly a natural initial concept.
But a more common practice would be to pass each piece of information that you want to in your OpenArgs parameter - delimited in your string and parsed back out in the called form.
For example an OpenArgs of

"-1;Purchase Orders;Status"

Ironically - you could also extract that from the single passed expression.
But as a general methodology the above is a standard concept and will be useful in a variety of situations.
brandon000
Thanks guys for responding...

I guess in my mind here's how it plays out. This expression has two value roles.

Role 1 - The expression makeup value which is "Forms![Purchase Orders]![Status]"
Role 2 - The value of the expression which is "-1".

"-1" being the value and "Forms![Purchase Orders]![Status]" being the expression that gives the value.

I would like to run this function on Form 2 or any form to know how to handle the event from which ever form it comes from dynamically so that all forms can share the same Form 2 without having to declare conditions for every form it comes from. I hope this makes sense, but if there is an easier way or other way, I'm all ears.

My Function......

Private Sub Cancel_Click()

Dim TextBox as Text 'TextBox = Forms![Purchase Orders]![Status]
Dim Value as Integer 'Value = -1

If (Value = 0) Then
TextBox = -1
'Else
TextBox = 0
End If

DoCmd.Close

End Sub


Edited by: brandon000 on Sat Jan 27 21:57:22 EST 2007.
brandon000
Any ideas on resolving this?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.