How to get a control's default value to update when changing recor

E

Eric in LA

I have the following situation:

In a Form, I have an Unbound Control whose Default Value is equal to a Bound
Control in the Record Source, but when I change from record to record, the
Unbound Control does not update (though the Bound Control does). It stays on
whatever Default Value was put in place when the form was first opened. Is
there any way to make the Default Value update itself?

I'm using Access 2003 on Windows XP.

Here's the background (if you need it):

A form whose Record Source is a Query that pulls from two tables. Table 1
contains information on specific products. Table 2 contains default
information on product types. There is a many-to-one relationship between
Table 1 and Table 2.

I am trying to set up an interactive spreadsheet where the line item
costs/estimated income for a specific product start off as default numbers
(based on the product type), but can be changed and saved to the specific
product itself without changing the defaults. I've set this up where the
Bound Controls for the Defaults brings the information in from the Query
(Table 2), then the Unbound Controls read the defaults and act as a
"workspace", then, when the User is ready to save, a Command button is
clicked to cause the Bound Controls of the specific record (through the Query
to Table 1) to update to whatever is currently in the Unbound controls. It
works perfectly as long as I open one record at a time, but I need to be able
to run reports for multiple records at once, and the default values stay the
same no matter what.

Thanks in advance!
 
N

Nitestalkernet

I hope this is what you need

in default value block of the unbound control enter some thing like this
"=[Forms]![Constants]![applyQueryFilters]"

My [Constants] is an empty form bound to the Query that other forms update
through, its purpose, open on load, close on exit, keeping the values
available for forms and reports not bound to that table or query.

There may be other ways to do this, but this seems to work quite well in my
applications, since the values passed to the form update any time data
changes in the queried tables.
 
M

Marshall Barton

Eric in LA said:
I have the following situation:

In a Form, I have an Unbound Control whose Default Value is equal to a Bound
Control in the Record Source, but when I change from record to record, the
Unbound Control does not update (though the Bound Control does). It stays on
whatever Default Value was put in place when the form was first opened. Is
there any way to make the Default Value update itself?

I'm using Access 2003 on Windows XP.

Here's the background (if you need it):

A form whose Record Source is a Query that pulls from two tables. Table 1
contains information on specific products. Table 2 contains default
information on product types. There is a many-to-one relationship between
Table 1 and Table 2.

I am trying to set up an interactive spreadsheet where the line item
costs/estimated income for a specific product start off as default numbers
(based on the product type), but can be changed and saved to the specific
product itself without changing the defaults. I've set this up where the
Bound Controls for the Defaults brings the information in from the Query
(Table 2), then the Unbound Controls read the defaults and act as a
"workspace", then, when the User is ready to save, a Command button is
clicked to cause the Bound Controls of the specific record (through the Query
to Table 1) to update to whatever is currently in the Unbound controls. It
works perfectly as long as I open one record at a time, but I need to be able
to run reports for multiple records at once, and the default values stay the
same no matter what.


I think your concept of the default value property is
flawed. First, the default value of an unbound control is
apploed when the form is loaded, so, as you are seeing, it
can not possibly be different from one record to another.

Second, the default value of a bound control is applied with
the first keystroke ***on a new record***. The default
value has absolutely no interaction with existing records.

I don't have a good grasp of what you are trying to do with
all this, but I think your idea of using any kind of
defaulted value on existing records needs to be rethought.

Maybe you need to use the product control's AfterUpdate
event to set the price control's value???

Me.price = DLookup("productprice", "products", _
"product = " & Me.txtproduct")

BUT, this is only useful if the price text box is bound to a
price field in the form's record source table.
 

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

Top