Help with figuring an expiration date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form called "Training" which is a form and a subform. It allows
someone to select the employee then enter the training, date taken, and
expiration date. The training field is a combo box which pulls from a table
called "tblTraininList"

I did have a function in the control on the DateExpires field, but since
some trainings or things we track don't have a set expiration date, such as
car insurance, that didn't work since it wouldn't let someone overwrite it
since it was bound to a code. I got a suggestion to bind the DateExpires
field to my training table and just add a column to my tblTrainingList with
the number of years each training is good for. This would allow for easy
edits if a new training was added. Here is what they told me to put, but I
coudln't get it to work

I was to put this code in the AfterUpdate events of the Training field and
DateTaken field

If Training.Column(2)>0 Then DateExpires =DateAdd
("yyyy",TrainingColumn(2),DateTaken)

I did that but it didn't do anything. My row source for the Training field
is this:
SELECT tblTrainingList.Training, tblTrainingList.Description,
tblTrainingList.NumberofYears
FROM tblTrainingList;

Is there something wrong here?
 
Shanin said:
I have a form called "Training" which is a form and a subform. It allows
someone to select the employee then enter the training, date taken, and
expiration date. The training field is a combo box which pulls from a table
called "tblTraininList"

I did have a function in the control on the DateExpires field, but since
some trainings or things we track don't have a set expiration date, such as
car insurance, that didn't work since it wouldn't let someone overwrite it
since it was bound to a code. I got a suggestion to bind the DateExpires
field to my training table and just add a column to my tblTrainingList with
the number of years each training is good for. This would allow for easy
edits if a new training was added. Here is what they told me to put, but I
coudln't get it to work

I was to put this code in the AfterUpdate events of the Training field and
DateTaken field

If Training.Column(2)>0 Then DateExpires =DateAdd
("yyyy",TrainingColumn(2),DateTaken)

I did that but it didn't do anything. My row source for the Training field
is this:
SELECT tblTrainingList.Training, tblTrainingList.Description,
tblTrainingList.NumberofYears
FROM tblTrainingList;

Is there something wrong here?
Hi,

The only thing I see wrong could be a typo, if you didn't copy and paste the
code.

It should read ...

If Training.Column(2)>0 Then DateExpires =DateAdd
("yyyy",Training.Column(2),DateTaken)
--

The dot is crucial :-)


HTH

MFK.
 
Hi,

If you want this calculated data to be displayed as you change the
selections in the two controls, then you'd be better off putting your code
in the change event , or possibly the lost focus event as the change event
fires for every keypress so the displayed data will do strange things while
you type.

You might want to consider having a button to calculate the value, you can
be sure that it will be executed at the right time then :-)

The after update event will only fire after the current record has been
saved.

HTH

MFK.
 
Back
Top