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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf Statement in DLookup 1

Status
Not open for further replies.

larrydavid

Programmer
Jul 22, 2010
174
US
Hello, I have a DLookup function which is returning a "Milestone" value which I am trying to display as a Y or N instead of 1 or 0. Below is the txtWBSMilestone field, the first line which is the original that works, the second which has the IIF statement I am using to try and return an Y/N value:

Private Sub Form_Open(Cancel As Integer)
Dim strKey As String
With Me
If Not IsNull(Me.numWBSLink) Then
strKey = DLookup("Key", "tbl_StepbyStep", "[RecID] =" & Me.numWBSLink)

!txtWBSMilestone = DLookup("Milestone", "tbl_StepbyStep", "[RecID] =" & Me.numWBSLink)

'!txtWBSMilestone = DLookup("IIf ([Milestone] = True,'Y','N') AS Milestone", "tbl_StepbyStep", "[RecID] =" & Me.numWBSLink)

End If
End With
End Sub

Here is the error I get when trying to go back an edit the form:
Run-time error '3075':
Syntax error (missing operator) in query expression 'IIF([Milestone] = True, 'Y','N') AS Milestone'.

Is what I'm trying to do even possible within a DLookup function?

Thanks,
Larry
 
Format the returned value. Something like
= iif(NZ(DLookup("Milestone", "tbl_StepbyStep", "[RecID] =" & Me.numWBSLink),"N"),"Y","N")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top