Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Variable ???? 3

Status
Not open for further replies.

nag9127

Technical User
Mar 15, 2007
76
US
I have a line in the Close event of a modal pop up form which is designed to send a value to the control in the form from which the modal form pops up. The modal form is called up via the On_Click event of that control. The line in the Close event of the modal form that is creating the problem is....

Code:
glblCalcBas.Value = Me.Calculation

glblCalcBas is a global variable created in Module1 with this code....

Code:
Public glblCalcBas As Access.Control

The calculation in the modal form is accomplished through this code....

Code:
Dim Basis As Double
Dim ClcFld As Double

Basis = Me.ConversionFactor.Value
ClcFld = Basis * 224
Me.Calculation = ClcFld

DoCmd.Close

And this is producing the "Object variable or with variable not set" error. Run time error '91'.

Any help would be greatly appreciated. Thank you!
 
Do you have the following on the control's click event?

Code:
Set glblCalcBas = Me!ControlName
 
How are ya nag9127 . . .

What you want is a variable, not an object. Objects have to be [purple]Set[/purple].

Try this:
Code:
[blue]Public glblCalcBas As Double[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
TheAceMan1...

I understand your point about the object and changing it to a variable will definitely eliminate the error message.

But I need to get that value back into the active control of the form from where the modal form was called up with the double click. So I need some link (variable/object ???) back to that control to assign it the calculated value from the modal form after the modal form closes. How do I do that?
 
Did you make sense with lameid's question ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You guys are smart and I feel like an idiot/moron. I had remarked out the line in the Double Click event when I was trying to isloate the code for testing/editing purposes and I never did away with the remark! I used all your responses to resolve the issue and it works properly now.

I left the public object variable as is and used 'Set' to assign the value to the object (that's what caused the original object variable error I was getting). Actually to answer lameid's question what I have in the Double Click event is this...

Code:
Set glblCalcBas = Screen.ActiveControl
DoCmd.OpenForm "ConversionForm2"

And PHV, thanks to your prodding about his question, I went back and looked to find the exact syntax I used and, lo and behold, it was remarked!

Thanks to all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top