DateAdd - OnProcessData [...] 'DateAdd' Follow

0
Avatar
Pascal Laframboise

Hello fellow VBscripter, 

 

I'm currently trying to make a label with today date and expiration date using a DB day field.

 

Here's the script : 

expdate = DateAdd("d", Field("BD_bartender.Boulangerie_us.Durée de vie"), Format.NamedSubStrings("date").Value)

Select Case Month(expdate)

Case 1 value = "JAN"
Case 2 value = "FEB"
Case 3 value = "MAR"
Case 4 value = "APR"
Case 5 value = "MAY"
Case 6 value = "JUN"
Case 7 value = "JUL"
Case 8 value = "AUG"
Case 9 value = "SEP"
Case 10 value = "OCT"
Case 11 value = "NOV"
Case 12 value = "DEC"

End select

value = value & "-" & Day(expdate) & "-" & Right(Year(expdate), 2)

 

When I click Test Script. It give me JUL-07-19.

But when I print the label, I got this error : 

OnProcessData(Line 3): : Argument .... incorrect: 'DateAdd'.

 

I can't figure out what's wrong. 

 

Many thanks,

 

 

1 comments

0
Avatar
Pete Thane
Comment actions Permalink

Hi Pascal,

I guess you noticed the expdate and dateexp mix up and have fixed that already.

I believe the issue could be when the VB is trying to perform it's action. As you are using information taken from a database then the VB script needs to run after the information has been read into the file. To do this you will need to change the VB type to an Event Controlled Script and (from the look of the above) the OnNewRecord instance option.

Pete 

 

Please sign in to leave a comment.