- Joined
- Jun 10, 2012
- Messages
- 7
- Reaction score
- 0
I am trying to get a function to work
The function has two arguments which take a meter serial number and a date and takes the form of an IF , Else If , Else structure
I want to check for a null value in the first passed argument and if null to pass the statement
" No Meters Fitted"
I then want to if there is a value in the meter serial number field check the date against todays date and return a value if the date is within 20 days of todays date and a different value if its over 20 later than todays date.
This is my function but when i run in a query i get ERROR. I did try If IsNull instead of Len but that didn't work either.
Can anyone out there please help me
Public Function mySiteStatusUpdate(ByVal prmElecMsn As String, ByVal prmHoDate As Date) As String
If Len(Nz(prmElecMsn, 0)) < 4 Then
mySiteStatusUpdate = " Not Metered"
ElseIf Not IsNull(prmElecMsn) And prmHoDate > DateAdd("d", 20, Date) Then
mySiteStatusUpdate = "Metered and pending"
Else
mySiteStatusUpdate = " Metered and Urgent"
End If
The function has two arguments which take a meter serial number and a date and takes the form of an IF , Else If , Else structure
I want to check for a null value in the first passed argument and if null to pass the statement
" No Meters Fitted"
I then want to if there is a value in the meter serial number field check the date against todays date and return a value if the date is within 20 days of todays date and a different value if its over 20 later than todays date.
This is my function but when i run in a query i get ERROR. I did try If IsNull instead of Len but that didn't work either.
Can anyone out there please help me
Public Function mySiteStatusUpdate(ByVal prmElecMsn As String, ByVal prmHoDate As Date) As String
If Len(Nz(prmElecMsn, 0)) < 4 Then
mySiteStatusUpdate = " Not Metered"
ElseIf Not IsNull(prmElecMsn) And prmHoDate > DateAdd("d", 20, Date) Then
mySiteStatusUpdate = "Metered and pending"
Else
mySiteStatusUpdate = " Metered and Urgent"
End If