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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expressions in SubForms

Status
Not open for further replies.

TadyB

Programmer
May 21, 2004
42
US
I have a subform that I need to perform a calculation in. One of the objects to be calcualted is a field, and the other is a text box. I set up a third text box to perform the calculation in its control source.
It looks like this:

Control Source: =[SmSoda]*[SmSodaPrice]
SmSoda is a field and SmSodaPrice is the text box.

All the formats are the same...general number. I keep getting the #Name error. If I use two fields on that subform to multiply, I don't get an error. It seems to be wrong only if I use the text box object in the calculation.
I've tried the same thing on my main form and everything works fine. So, I've narrowed it down to the subform not being able to recognize the text box within itself.
I've also tried using:
=Forms![Drinks Subform1].[SmSodaPrice] * [SmSoda]
and that didn't work either.

Any ideas as to why and how to solve this? I'm trying to avoid setting up more macros or adding more fields in order to get this done.

Thanks,
Stacey
 
Have you tried this ?
Forms![Main Form]![Drinks Subform1].Form![SmSodaPrice] * [SmSoda]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Seems to work now. I must have been typing something wrong, but I tried it again as I originally had it and it worked. Go figure. Guess I shouldn't be staying up all night working on this!!

Thanks anyway!

Stacey
 
Ok, maybe I'm not so insane..check this out:

The only reason it worked is because I changed the Name of the Text Box to "s" (I got tired of typing SmSodaPrice). If I change it to any other letter or any other name, it won't work!!!

I really don't get what is going on here. Any thoughts?

I'm using Access 2000.

Stacey
 
Sorry to keep posting so much...

I gave up...got out of Access and then went back in and it's working with whatever name. Must be some kind of save or refresh thing. I dunno.

Think this is something I have to worry about in the future?

Stacey
 
Some hints:
Never forgot to Save (the diskett icon) before testing.
Regularly compile the code.
Always test with a copy of the database (or make verified backup of the database before testing)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top