Solved

can't update an unbound field in Datasheet view for current record without updating all records

Posted on 2004-09-06
2
857 Views
Last Modified: 2008-03-17
This should hopefully be an easy one, but I can't seem to figure it out.  I have a form being displayed in "Datasheet View" in microsoft access.  The datasheet view has several columns.

example:  ID, ColumnA, ColumnB, ColumnAB

Now, lets say that "ColumnAB" is unbound, but "ID", "ColumnA", and "ColumnB" are bound to fields in a certain table in a database.  ColumnAB is unbound because I just want to display the results of a simple calculation after values have been input into ColumnA and ColumnB without actually storing anything in the database.  Here is an example of the code I would write inside a function that would be called when the value of either ColumnA or ColumnB changes...

If [ColumnA].Value And [ColumnB].Value Then
        [ColumnAB].Value = [ColumnA].Value + [ColumnB].Value
End IF

Everything appears to work fine when I'm typing in my first record, the value of ColumnAB will update and display the correct result.  The problem occurs when I add/switch to another record (I'm in Datasheet view, so this form is showing all the records in the table at the same time).  If I switch to record 2 and change the value of ColumnA, then it calls my function to update the value of ColumnAB.  The problem is that the code [ColumnAB].value seems to update the value of ALL [ColumnAB] fields, and not just the one for the current record.  What do I need to change in my code to only refer to the [ColumnAB] field of the current record, and not change all values in the whole form?

Thanks in advance
0
Comment
Question by:nexisvi
2 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 50 total points
Comment Utility
You can't. This is normal behaviour - when in datasheet or continuous form view with unbound forms. If you want to include a value that is calculated on a per-row basis, you'll need to either make it a calculated field in the form's underlying query, or a calculated control (i.e. a formula in the text box's Control Source) on the form.
0
 

Author Comment

by:nexisvi
Comment Utility
It makes sense I guess.  I'll just include the formula as a calculated field as you suggested.  Thanks for your help.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now