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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with updating Dates in Field

Status
Not open for further replies.

JimUK

Technical User
Jan 1, 2001
57
US
I have a form that show preventive maintenance info and 2 of the fields are "Date Completed" and "Date Due". What I need to do is when a user calls the form up to fill in the new date complete, I need the Date Due field to update to the new date, (this will be 7 days for weekly, 30 days for monthly, 90 days for quarterly and 1 year for anually. What would be the best way to go about this and also where would I put it, in the before update perhaps. Thanks in advance


Jim
 

Do you mean you want, after typing in "date completed" a calculation to happen, and the new date appears in "date due"?

so, if you want the date due in 7 days time

before_update

txtdatedue = txtdatecompleted + 7

same thing - if you want date due in 30 days time

txtdatedue = txtdatecompleted + 30

 
Yes, that's exactly what I want to do, but depending on another field in the table, which will have weekly, quarterly, etc, depending on the periodicity of the maintenance.
So it's not as simple as like a calculated control then because of the different possibilities, will there need to be some code behind the scenes?
 
I am sorry, but I do not really understand what you are talking about, but I can suggest something. Have you thought about hidden text boxes which will include a value that can affect the results: -

e.g

Make four text boxes in your form with visible set to No.
Name them as
Txtweek
Txtmonth
txtquarterly
txtyear

and their text value can be different, depending on the table value which could be 7, 30, etc

then, before_update for weekly

txtdatedue = datecomplete + txtweek


or for month

txtdatedue = datecomplete + txtmonth

or for year

txtdatedue = datecomplete + txtyear

etc
 
Ok, le tme try to put it together. The form I'm using is for signing off completed preventive manitanance procedures. The fields on it are pmNum (procedure number), pmSys (what system it's being performed on), pmComplete (date of completion), pmDue (due date of next completion), pmPeriod (period in which maintanance has to be done...weekly,monthly,etc), pmInitials (initials of person completing) and pmComments (general comment field).
All I need to do is when someone completes a job, the query calls up the particular pmNum and the Tech enters the pmComplete with the current date, from this date depending on what the contents of pmPeriod is, (could be a job that gets done weekly, monthly, etc) I want to automatically update pmDue with the new Due date. Anotherwords, if its a job that is done monthly, they would enter 2/18/2003 in the pmComplete field and the pmDue field should automatically update to pmComplete date plus 30 days.
I am using the same form for all Periods, i.e weekly, monthly,Quarterly, yearly. And would like this form to show update before exiting and save to table.
I hope this helps and thanks again for you response.

Jim
 
Ok.

Lets start with some ideas.

Why not have a blank form, with a combobox, which contains all the pmnum.

When a pmnum is selected by the tech, make a text box appear with a command button, and the tech could enter in the current date into the textbox, or make some code to automatically make the current date on the computer be in the text box. (txtdatecomplete = date )etc

So, now the tech could click on the command button. The coding behind the command button could make all the other fields become visible.

using some coding, you could update the pmComplete with the txtdatecomplete.text value which the tech has just entered in.

Other coding will ensure that the pmdue text box will be updated automatically, according to the rules of the other pmperiod etc

Is this good enough idea for you? I am only trying to help to give you ideas. Just let us know.
 
That sounds like a good idea. My only question is how do code the command button to make all the boxes I need become visible? I think i can figure the rest.

Jim
 

Set all the property of the textboxes you want visible = no
then in the coding

on click of command button

textbox.visible = true
textbox1.visible =true


hope it helps

let us know of your progress

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top