Monthname In Onprocessdata Script Follow

0
Avatar
Legacy Poster

We are having problems with the following OnProcessData field script:

Dim receiptDate, inventoryDate

receiptDate = right(Field("ZXAI_bridge_receipts.ddta"), 2) + mid(Field("ZXAI_bridge_receipts.ddta"), 3, 2) + left(Field("ZXAI_bridge_receipts.ddta"), 2)
inventoryDate = left(Field("ZXAI_bridge_receipts.inventoryDate"), 2) + mid(Field("ZXAI_bridge_receipts.inventoryDate"), 4, 2) + mid(Field("ZXAI_bridge_receipts.inventoryDate"), 7, 2)
inventoryDateFormat = mid(Field("ZXAI_bridge_receipts.inventoryDate"), 7, 2) + " " + MonthName(mid(Field("ZXAI_bridge_receipts.inventoryDate"), 4, 2), True) + " 20" + left(Field("ZXAI_bridge_receipts.inventoryDate"), 2)

If inventoryDate > receiptDate Then
	Value = "Use before: " + inventoryDateFormat
Else
	Value = ""
End If 

We I run Test, then it shows this error:

<Line 10 : Invalid procedure call or argument: 'MonthName'>

However if I ignore this error and save this label, then it will print the month name. But if "ZXAI_bridge_receipts.inventoryDate" is empty, then it will not print the label.

 

So this problem is twofolded:

- Why it doesn't recognize "MonthName" as a function?

- And how can we print labels if "ZXAI_bridge_receipts.inventoryDate" is empty?

 

2 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Perhaps you need to specify a default value for a database field?  Do this by setting an additional argument in the field reference.  For example: Field("TableName.FieldName", 1)

0
Avatar
Legacy Poster
Comment actions Permalink

Perhaps you need to specify a default value for a database field?  Do this by setting an additional argument in the field reference.  For example: Field("TableName.FieldName", 1)

 

Unfortunately that doesn't work. At the end I solved it in a less clean way, but it works:

 

Select Case month
	Case "01"
		monthName = "Jan"
	Case "02"
		monthName = "Feb"
	Case "03"
		monthName = "Mar"
	Case "04"
		monthName = "Apr"
	Case "05"
		monthName = "May"
	Case "06"
		monthName = "Jun"
	Case "07"
		monthName = "Jul"
	Case "08"
		monthName = "Aug"
	Case "09"
		monthName = "Sep"
	Case "10"
		monthName = "Oct"
	Case "11"
		monthName = "Nov"
	Case "12"
		monthName = "Dec"
	Case ""
		monthName = ""
End Select 

Please sign in to leave a comment.