Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric in LA - 26 Sep 2006 00:47 GMT
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!
Nitestalkernet - 26 Sep 2006 06:18 GMT
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.

> I have the following situation:
>
[quoted text clipped - 27 lines]
>
> Thanks in advance!
Marshall Barton - 26 Sep 2006 16:01 GMT
>I have the following situation:
>
[quoted text clipped - 25 lines]
>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.

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.