0
votes

Sorry, I’m pretty new at Access so I might not be using some terms correctly (or might not know some terms at all).

I’m encountering an ‘Enter Parameter Value’ error when I put my subform1 into my mainform. On subform1 I have a button that runs query1, query2, query3. These 3 queries query tables and also calculated fields that are located on subform1. Subform1’s data source is query4. When I press the button (with 3 queries), everything works.

Once I place that subform1 onto my mainform (so that my user can press the button to run the queries without entering the subform1) I receive an ‘Enter Parameter Value’ error. Query1, query2, query3 are unable to find those calculated fields located on subform1. For example the ‘enter parameter value’ error is as follows: Forms!subform1!calculatedfield1. I’ve tried changing the ‘location’ to things like: Me.subform1!calculatedfield or Form!mainform1!subform1!calculatedfield but I still receive that same parameter error. I could move the calculated fields to mainform1, which makes the queries work fine. But I would like to keep all of the calculated fields on the subform. Does anyone have any suggestions?

1
If your button is on the subform and you're referring to another control on the same subform then just use the me!calculatedfield to refer to that control. i.e. no need to refer to subform since you're already there.geeFlo
That's what I thought as well, but I still received the parameter error. Just for clarification, the button will run query1 which looks like this: UPDATE table1 SET table1field = Forms!subform1!subform1calculatedfield WHERE (((table1field) Between Forms!subform1!subform1calculatedfield And Forms!subform1!subform1calculatedfield2)xpandamonium
Perhaps a better way to state the problem: I have the query open and the mainform1 open (with subform1 contained within it). When I run the query, it can't find the calculated fields on subform1. But subform1 is clearly open on mainform1.xpandamonium
And I'm guessing you're running that string with a dbs.execute or something like that. Try "UPDATE table1 SET field = '" & forms!sub!field & "'"geeFlo
sorry, that didn't work either, thanks for the help thoughxpandamonium

1 Answers

0
votes

I always name subform container control different from the object it holds, such as ctrDetails. Then this works for me:

Forms!Main!ctrDetails!fieldname

However, my preference would be to run SQL statement in VBA. So code behind button could be like:

CurrentDb.Execute "UPDATE table1 SET table1field = " & Me.subform1calculatedfield & _
" WHERE table1field Between " & Me.subform1calculatedfield & " And " &  me.subform1calculatedfield2 

Why do you need to save calculated data?