Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating date box in a form - possible?

Status
Not open for further replies.

pumog

Technical User
Joined
Sep 26, 2003
Messages
6
Location
GB
Hi

I'm running a database at a hospital for research purposes about patients with a certain condition. I want to have a box which keeps a running total of how many days they have survived since operation. I haven't worked out how to do it all in Access but I can do it in Excel - or I could if there was a way of having a record which shows "today's date" and updates each time you open it - then various calculations could be linked to it which would give the necessary data. Can I insert a "today's date" box with automatically updates?

Thanks
 
Put a text box on your form with is control source =Now()
 
Hi

If you just want date not time then =Date() would do it

If you want to know days between two dates then look at DateDiff(), eg

DateDiff("d",OperationDate,Date())



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thank you very much for your help - I'm going to try it! I haven't much experience in putting commands in so I might be back..... thanks again
 
Hi

I worked out the 1st two suggestions which are fine, then I tried =DateDiff("d",25/9/3,Date()) just to see what happened, and I keep getting 37890... what am I doing wrong, please?! Thanks very much
 
Hi

=DateDiff("d","25/09/03",Date())

without the quotes it is taking 25 divided by 9 divided by 3 rather than the date you intended

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Fantastic, done it!! One last question... it only works if I input a specific date, but my data base has hundreds of different patients in it with different operation dates, and will of course keep growing. How do I get the sum to refer to any date within "Operation Date" (which is in the same table as all the other data) rather than a specific date? Thank you so much
 
Hi

Well you would make a query based on the patients table, include in the query teh columns you are interested in, plus make yourself a calculated column say:

SurvivalDays:DateDiff("d",[OperationDate],Date())

using the appropriate column name from your table for the date of the patients operation.

OK?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi

I managed to do what you said, but problem is that when I open the form it shows ALL the data (ie survival days for all the patients) rather than just for the particular patient whose record we are viewing. All the other tables are linked in by operation number so I've added the same kind of relationship for the query, but I wonder if there is a way to only show the data of the patient we are viewing. Thanks very much!
 
Hi

Put a criteria on the query which limits the data returend to the patient in question, I cannot be more precise without knowing how you are viewing the data ie via a form or directly in the table (not a good idea), I do not want to be rude but it sounds to me like you could benifit from reading an Access Book - Access Developers Handbook is excellent.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
OK great you are right - couldn't find an appropriate course and wasn't sure what book to read! Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top