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!

Auto complete table field 1

Status
Not open for further replies.

HacH

Programmer
Dec 24, 2002
27
GB
Hi,

I am trying to produce a table in Access 97. There are 2 date fields, the first is entered by the user and I would like the second field value to be completed automatically with the value of the first field + 3 years.

For example Issue_Date = 10/10/2000
then Renewal_Date should = 10/10/2003

I would be greatful if someone could resolve this for me. I have managed to get it working partly but it is currently taking the current date rather than the date in the Issue_Date field.

Many Thanks
 
in after update property in vba window
dim strdate as string

strdate= forms!myform!issuedate.value

if me.issue_date is null then
else
me.renewal_date = datepart("m",strdate]) & "/" & datepart("dd",strdate) & "/" & (datepart("yyyy",strdate) +3)

end if

I Didn't test this but if you look up datepart function and get the right form reference you should be able to make something like this work for you. hth
 
Are you performing the update in a form?

Assuming the fields are called "Field1" & "Field2" you could manage the change in the After_Update event of Field1

Sub Field1_AfterUpdate()
Me.Field2 = CDate(Day(Me.Field1) & "/" & Month(Me.Field1) & "/" & Year(Me.Field1) + 3)
End Sub

Of course you might want to include some validation to confirm the value in Field1 is actually a date before you apply the value to Field2

Tudor

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
Code:
Private Sub Issue_Date_AfterUpdate()
Me.Renewal_Date.Value = DateAdd("YYYY", 3, Me.Issue_Date.Value)
End Sub

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Thank you all for your speedy response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top