Hi Everyone,
I am in a bit of a pickle and need some expert advice. I have a db in access. I am trying to create a query with fields from the tables. In my query I need to take the value of one field and depending on what the value is pull a date from other fields. I have tried a IIF and it errors. Tried to write an if-then-else function ( which I doubt I did right since I have never done one) and I get an undefined expression error.
So for my example it would be from the function I wrote....
Public Function StatusDate(Stat usDate)
If [WO Info Main]![WO Status] = 1 Then
StatusDate = [WO Info Main]![Final Date Received for Estimate]
Else
If [WO Info Main]![WO Status] = 2 Then
StatusDate = [WO Info Main]![Date Estimate Completed]
Else
If [WO Info Main]![WO Status] = 3 Then
StatusDate = [WO Info Main]![FD Assign Date]
Else
If [WO Info Main]![WO Status] = 4 Then
StatusDate = [WO Info Main]![FD Approval Sent Date]
Else
If [WO Info Main]![WO Status] = 5 Then
StatusDate = [WO Info Main]![Development Assign Date]
Else
If [WO Info Main]![WO Status] = 6 Then
StatusDate = [WO Info Main]![Test Deploy Date]
Else
If [WO Info Main]![WO Status] = 7 Then
StatusDate = [WO Info Main]![Production Deploy Date]
End If
End If
End If
End If
End If
End If
End If
End Function
Can someone tell me if this is something I can do or if there is another way. Any help would be much appreciated and any ribbing as well. Thanks.
I am in a bit of a pickle and need some expert advice. I have a db in access. I am trying to create a query with fields from the tables. In my query I need to take the value of one field and depending on what the value is pull a date from other fields. I have tried a IIF and it errors. Tried to write an if-then-else function ( which I doubt I did right since I have never done one) and I get an undefined expression error.
So for my example it would be from the function I wrote....
Public Function StatusDate(Stat usDate)
If [WO Info Main]![WO Status] = 1 Then
StatusDate = [WO Info Main]![Final Date Received for Estimate]
Else
If [WO Info Main]![WO Status] = 2 Then
StatusDate = [WO Info Main]![Date Estimate Completed]
Else
If [WO Info Main]![WO Status] = 3 Then
StatusDate = [WO Info Main]![FD Assign Date]
Else
If [WO Info Main]![WO Status] = 4 Then
StatusDate = [WO Info Main]![FD Approval Sent Date]
Else
If [WO Info Main]![WO Status] = 5 Then
StatusDate = [WO Info Main]![Development Assign Date]
Else
If [WO Info Main]![WO Status] = 6 Then
StatusDate = [WO Info Main]![Test Deploy Date]
Else
If [WO Info Main]![WO Status] = 7 Then
StatusDate = [WO Info Main]![Production Deploy Date]
End If
End If
End If
End If
End If
End If
End If
End Function
Can someone tell me if this is something I can do or if there is another way. Any help would be much appreciated and any ribbing as well. Thanks.
Comment