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

automatic expiry field

Status
Not open for further replies.

redeyes1965

Technical User
May 12, 2001
76
GB
i have a table with an issued field and an expires field. they are both date fields. i want the expired field to be filled in automatically, putting the date exactly one year from the issued field.

can it be done and if so how??
 
When you create the form for data entry (and you should be using a form!), in the afterupdate event of the issued field, put the following code:

Me![expireddate] = DateAdd("yyyy", 1, Me![issueddate])

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
thnx mstrmage1768

you read me well, a slacker lol = no form = you should be a mistic lol.

can i get away with doing this in the properties of the issuedate feild.

i will get around to a form, promise, maybe even in VB who knows lol

thnx again

tim
 
To my knowledge...no. There are no exposed events that I am aware of you would be able to do this with. Which is why I suggested a form to enter data (not because you are a slacker! [smile]).

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Just joking, appreciate your help :)

Anyway, created a form as per your advice with a new record button and a save button, and the expression in the after update section of the properties for the issued field looks like this

=[kar]![expires]=DateAdd("yyyy",1,[kar]![issued])

problem is nothing is being put in the expired field for new records + do i have to change the yyyy to the format i am usinf for instance ddmmyy etc ?

thnx again
 
Assuming your form name is "kar"...you should have the following in the afterupdate event of the issued field:

Me![expires] = DateAdd("yyyy",1,Me![issued])


=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
I wouldn't store the Expires date in the table because you can always calculate it from the issue date. The only reason to have a separate field in the table is if there are times when you want to manually override the 1-year rule.
 
Actually no, kar is tha main table name and was automatically inserted when i used the expression builder to navigate to and insert the exact fields.

so in your example, what is Me!?

Thnx

Tim
 
Me! is the name of your form that you are going to create! (actually a short hand way of referring to the name of the current form that has the focus).

btw... I totally agree with JonFer. DO NOT STORE CALCULATED VALUES. Sorry for shouting, but it's a fundamental issue.
 
I think i must be thick. i just cannot get this to work, what am i doing wrong. if i use me! i always get the error "the object does not conatin the automation object 'me.'.

if i take out the me, i get no error but the expired field does not get filled in

any ideas.

hope i am not being pain

thnx for all your help;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top