473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to store calculated control value in ms access 2000 database

i am new to this ms access 2000. i have created a form in that i have created calcualte control. the calculated control value is not storing in the datebase.
Anyone pls help me.

Thanks
Nov 12 '07 #1
14 3869
Jim Doherty
897 Expert 512MB
i am new to this ms access 2000. i have created a form in that i have created calcualte control. the calculated control value is not storing in the datebase.
Anyone pls help me.

Thanks

Hi sarahraj,

Please explain a little more about what it is you are trying to achieve so that contributors can answer you more precisely

Thanks

Jim :)
Nov 12 '07 #2
I am using ms access 2000. In form i created 3 textbox controls. I am entering the two dates.i am calculating difference between the months for this i used this exp:
txtMonthsOverdue=DateDiff("m",[txtTargetCompletionDate],[txtRevisedCompletionDate])

now the problem is the calculated value is displaying in the form but not in the database

Could you plzzzzzzz help me

Regards,
Sarah
Nov 14 '07 #3
missinglinq
3,532 Expert 2GB
Obviously, the first question that needs to be asked is "Is txtMonthsOverdue bound to a field in the underlying table/query?" In the Properties Box, does it have anything listed in the Control Source box?

Also of concern is your use of Month ("m") as your interval. Using "m" and the dates 10/31/2007 and 11/01/2007, DateDiff will yield 1 month, when, in fact, the two dates are only 1 day apart! Depending on your needs, using an interval of days ("d") perhaps would be better. If you want months and parts of months you could then divide the DateDiff product by 30 or 31.

Or I can give you a short bit of code that will take the difference in days and return the years/months/days between two dates.

Welcome to TheScripts!

Linq ;0)>
Nov 14 '07 #4
Control Source =DateDiff("m",[txtTargetCompletionDate],[txtRevisedCompletionDate])

it is displaying in the form. I want to store that value into table

Regards,
Sarah
Nov 14 '07 #5
missinglinq
3,532 Expert 2GB
Then the Control Source has to be a field in the underlying table, not an equation! And the equation has to be invoked elsewhere in your form, like in the AfterUpdate event of txtRevisedCompletionDate.

And please look at Post # 4 again; I've revised it addressing another concern with your code.

Linq ;0)>
Nov 14 '07 #6
in propertied i set control source=datediff("m",[txttargetcompletiondate],[txtrevisedcompletiondate])

this is the code:

Private Sub txtRevisedCompletionDate_AfterUpdate()
Me.txtMonthsOverdue = Me.DateDiff("m", [txtTargetCompletionDate], [txtRevisedCompletionDate])
End Sub
in monthsoverdue the value is displaying.i want to store that monthsoverdue textbox value into table.in my form everything is ok but storing value in database is the problem.

Regards,
sarah
Nov 14 '07 #7
missinglinq
3,532 Expert 2GB
Then, as I said before, you have to change the Control Source to the field in your table where you want to store the monthsoverdue! The AfterUpdate code will do the calculation for you, you don't need it in the Control Source as well!

And again, please note, that by using Months as your interval in DateDiff, you're going to show 1 month overdue even if the two dates are only 1 day apart, if you're talking about the last day of one month and the first day of the next!

Linq ;0)>
Nov 14 '07 #8
how to attach my application to you?
Nov 14 '07 #9
I have changed control source to field in my table.still not saving record in table.

i have to calculate only months between two dates.

thnx
sarah
Nov 14 '07 #10
missinglinq
3,532 Expert 2GB
Okay, this is kind of strange, but it's how it works!
Make a zip file first, then

Post another response to this thread
Immediately click on Edit/Delete
Scroll down until you see Manage Attachments
Click on this button
Browse until you find your database file
Click on UpLoad
Back out and click on Save Changes

That should do it!
I'll look at it and get back to you, if not tonight, first thing in the (EST) morning.

Linq ;0)>
Nov 14 '07 #11
Ok Thanks,

regards,
sarah
Attached Files
File Type: zip db1.zip (16.6 KB, 140 views)
Nov 14 '07 #12
missinglinq
3,532 Expert 2GB
Okay, Sarah! I'll take about 60 seconds to fix this!

First off, sometimes (not always) if you write code in the code editor without gaining access to the code editor by going thru the Properties box for a control, the control and the code are not, for lack of a better word, "connected!" In other words, although you have code for the OnClick event of a button, that code doesn't fire when the button is clicked. The answer to this is exactly what you need to do.

In Design View for your form, Right Click on your textbox txtRevisedCompletionDate. Click on Properties - Events. You'll notice that there's nothing in the AfterUpdate propertry box, although in fact you do have code for this in the code module! Click on the empty box, then click on [Event Procedure]. It should now appear in the box. Click on the ellipses (...) to the right of the box. You should be taken to the code window and in or near the code

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtRevisedCompletionDate_afterupdate()
  2. 'Me.txtMonthsOverdue = Me.DateDiff("m", [txtTargetCompletionDate], [txtRevisedCompletionDate])
  3. End Sub
You need to change two things in this code.

First, delete the apostrophe where you had this code commented out.

Second, change

Me.DateDiff("m", [txtTargetCompletionDate], [txtRevisedCompletionDate])

to

DateDiff("m", [txtTargetCompletionDate], [txtRevisedCompletionDate])

Notice that the Me. before DateDiff is gone!

So the code should now read

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtRevisedCompletionDate_afterupdate()
  2. Me.txtMonthsOverdue = DateDiff("m", [txtTargetCompletionDate], [txtRevisedCompletionDate])
  3. End Sub
Now, delete all the other code where you tried to do this, so you're only left with the txtRevisedCompletionDate_afterupdate() sub. The calculation will now be run and the results stored in your table.

Linq ;0)>
Nov 15 '07 #13
It is Working. Thanks for your kindly help.

I have another doubt. Suppose i have one combobox in that i want to add new items and that item will be display in that combobox list?

i used row source -value list.

Regards,
Sarah
Nov 15 '07 #14
hi,

y'day i tried your code it was worked. today i m going to add new items into table but it is not updating in the database.plz help me.

Regards,
sarah
Nov 16 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: imani_technology_spam | last post by:
I'm trying to create an OLAP system using SQL Server 2000 Analysis Services (AS). I want the AS cube to be based on a database with a star schema. I have a field called Ratio. The initial...
14
by: Allen Browne | last post by:
Subform is based on a single-table query that contains a calculated field: Amount: Round(CCur(Nz(*,0)),2) Continuous subform displays this field in a text box named Amount. As user enters new...
0
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that one of the...
2
by: david | last post by:
Hi, I have a form with a couple of calculated fields. I want to put some code into the 'Form-Load' event to set various object states on the form, depending on the value of these fields. The...
1
by: tconway | last post by:
I have an Access program that displays Customer data into a form and OrderID data into a subform. The totals in the Subform are based on calculated fields, i.e. the Total Amount field Calculates...
6
by: dhowell | last post by:
I have a "form" and "subform" where I would like a calculated control on the form which sums the values of a datasheet column of the subform. (datasheet on subform may have a variable number of...
2
by: John | last post by:
I am using Access 2000. One table in my database has a field called RankName. Values inlcude: Officer, Sergeant, Lieutenant. I need create a report that groups these three RankNames into two...
3
by: kelley.l.turner | last post by:
Hi all, I am very new to MS Access so please bear with me! I have created a simple calculated field in my data entry form, yet when I view my data table or try to generate a report based on...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.