i have a field on a form where a calculation is displayed. The field calculates the number of business days a request is due based on a priority level chosen from a drop down box.
i want to save the data in the calculated field on the form to a new field in the table that i recently created to store this number.
how would could i have this data save to this field when the form is saved?
4 2023
Hi
use the 'after update' event of the combo to update the destination field. you could actually use that destination field on your form instead of the unbound box, and perform the calculation within vba.
example:
you could use the If ... then... end if method but I prefer to use select case for options like this, apparently it executes more quickly and in any case I find it easier to write - Private Sub ctlCombo_AfterUpdate()
-
-
select case me.ctlCombo
-
case 1 'top priority
-
me.txtField = me.txtField + 1 'where txtfield is a date and 1 is 1 day
-
-
case 2 'normal priority
-
me.txtField = me.txtField + 7
-
-
case 3 'low priority
-
me.txtField = me.txtField + 28
-
-
end select
-
-
end sub
HTH
Kevin
While there are exceptions to the rule, in most cases calculated fields should not be stored in tables, and this is not a valid exception! Unless you expect the number of days that are assigned to Top, Normal and Low Priorities to change, the value should simply be re-calculated whenever it's needed, not stored in a table. Storage space aside, a calculation such as this will always be faster than retrieving data from disk.
Welcome to Bytes!
Linq ;0)>
Hi
use the 'after update' event of the combo to update the destination field. you could actually use that destination field on your form instead of the unbound box, and perform the calculation within vba.
example:
you could use the If ... then... end if method but I prefer to use select case for options like this, apparently it executes more quickly and in any case I find it easier to write - Private Sub ctlCombo_AfterUpdate()
-
-
select case me.ctlCombo
-
case 1 'top priority
-
me.txtField = me.txtField + 1 'where txtfield is a date and 1 is 1 day
-
-
case 2 'normal priority
-
me.txtField = me.txtField + 7
-
-
case 3 'low priority
-
me.txtField = me.txtField + 28
-
-
end select
-
-
end sub
HTH
Kevin
The Calculation is not the issue, the issue is saving the number of days that is produced in to a field in the table. For example where "______" represents a text box.
Due In __5___ business days
i want to save the "5" in the table. how do i make the data save along with the rest of the record.
or rather how to i associate the field in the form to a field in the table?
While there are exceptions to the rule, in most cases calculated fields should not be stored in tables, and this is not a valid exception! Unless you expect the number of days that are assigned to Top, Normal and Low Priorities to change, the value should simply be re-calculated whenever it's needed, not stored in a table. Storage space aside, a calculation such as this will always be faster than retrieving data from disk.
Welcome to Bytes!
Linq ;0)>
The reason i want the form to store the data is because i am going to have to alter a report to calculate the number of days that the request actuall took to complete and compare it to the number that was required.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jack |
last post by:
Hi,
This is a strange problem I am encountering. I have a asp page with a
confirmation.asp page that saves data to a table. There are few text fields
that are captured by the confirmation page as...
|
by: Eagle |
last post by:
Hi all,
I've constructed a database that handles data concerning the "flow" of
tooling in a factory. The problem is in receiving back the concerned tools
and storing this data in a table tbl_In....
|
by: dave |
last post by:
In A2000 I have a table containing a memo field. There is an unbound
form for entering text, and there can be lots of it. When the form
opens there is a function to grab the data from the table and...
|
by: Stuart McGraw |
last post by:
I haven't been able to figure this out and would
appreciate some help...
I have two tables, both with autonumber primary
keys, and linked in a conventional master-child
relationship. I've...
|
by: - |
last post by:
I had added a new field to a form, and try insert the data to the new
created table field. But when i try to assign the a control source for that
form field, in the control source drop down list it...
|
by: TORQUE |
last post by:
Hi,
Im wondering if anyone can help me with a problem.
I have a form with more than 50 unbound fields.
Some of the fields will be blank from time to time.
This seems to be where im having...
|
by: Kevin |
last post by:
I've been searching forever for examples of saving data changes in a
DataGridView. There's all kinds of examples, but none really show how
to save changes. Someone please help me.
I have a...
|
by: bettyboo |
last post by:
Hi
I'm new to the forum and also a VERY new user of Access to develop databases. I'm building a DB for a driving instructor acquaintance, and he wants a button on the pupil data entry form which...
|
by: AdamOnAccess |
last post by:
I'm in Access 2007. I built a feature that to saves the current list in a sub form to a separate table. It works like this: After entering a list of words in the subform, the user can choose to push...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |