Returning a value to current record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have some code written for a combo box On Change event on a form. I would
like to have the result of that code returned to a control on the current
record (the one that triggered the On Change event).

Here are the last two lines of my code:
Me.txtTest.SetFocus
Me.txtTest.Text = MinPeriod

The problem with this is it updates the txtTest control value on ALL the
records, not just the current one. Any suggestions?
 
It's usually happen when you try to assign a value to a text box in the form
that is UnBound ( is not linked to any field in the record source of the form)

If you don't want to link the text box to a field in the table, you just
want to display the value but you don't want to store it, then use the
control source of the text box to display the value

e.g
=[ComboName].column(1)
 
You are using an unbound control on a continuous form or datasheet. You need
to bind the control to a field in the underlying data source, or use a
single form subform. Or use an outside 3rd party grid control instead of a
subform.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
I think I might have a similar problem...

I have tables [Assy], [Parts], [Components], [ConnectAssytoParts]
[ConnectComptoAssy], [Type], and [Color].

Assy consists of columns
AssyKeyID, Assembly#, Type, Color,
-I have the fields Type and Color reference tables [Type] and [Color] by
using the lookup wizard. The bound field is 1 which = TypeID, the number of
columns =2, and the Column weiths = 0â€;1â€

Parts:
PartKeyID, Part#, weight/foot,

Components:
CompKeyID, Component#, weight,

ConnectAssytoParts:
CA2PID, Assy, PartKeyID, Length
-Like the table [Assy]

ConnectAssytoComp:
CA2CID, Assy Componet (KeyID)

I have a forms [AssyParts], [AssyComp], and [AssyMain]
In the forms [AssyParts] and [AssyComp]: you select an assy number and
assign a Part number to it. Both are continuous forms. At the bottom of the
forms (on the form Footers) are unbound text boxes ([AssyPartWtT] and
[AssyCompWtT]) with a control that sums the total weight of each Assy number.

Using my main form you can also assign parts and components to assemblies by
selecting parts/comps from a dropdown combo box in each respective Subform.
This builds a list of what is used to make each assembly.
My problem is I can not get the sum of the Components or Parts to show up on
the main form. I would like to have one unbound text box [AssyWtT] on the
body of the AssyMain form that gives the total weight of each assy and one
unbound text box in the form footer that totals the weight of each assy
[TotalWt].

Here are the controls for each unbound text box

[AssyPartWtT]:
=Sum([Length]*[WeightPerFoot])

[AssyCompWtT]
=Sum(Nz([CompWeight],0))

[AssyWtT]
=Sum(Nz(Forms!AssyComp!AssyCompWtT+Forms!AssyParts!AssyPartsWtT,0))

[TotalWt]
=Sum(Nz([AssyWtT],0))

Both [AssyWtT] and [TotalWt] are showing #Error in the text box.

What should these controls actually be so they work the way I want them to?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top