A
atlantis43 via AccessMonster.com
Wondering if anyone can suggest a way to simplify the following code, which
I’m using in the OnFormat event of a report.
If Not IsNull(DLookup("[ICD2]", "EntryICDs", "[EntryNum] = " & Me!
[PtAcct#])) Then
Me![Field192] = Replace(DLookup("[ICD2]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
End If
If Not IsNull(DLookup("[ICD3]", "EntryICDs", "[EntryNum] = " & Me!
[PtAcct#])) Then
Me![Field194] = Replace(DLookup("[ICD3]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
End If
If Not IsNull(DLookup("[ICD4]", "EntryICDs", "[EntryNum] = " & Me!
[PtAcct#])) Then
Me![Field196] = Replace(DLookup("[ICD4]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
End If
If I use the following code line alone:
Me![Field192] = Replace(DLookup("[ICD2]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
I the Replace function yields an errrmsg if the DLookup function is null
Is there any way to use an 'if isnull' function or an IIf function to
accomplish the If---Then clauses that I have included, so that the coding is
neater?
TIA, Richard
I’m using in the OnFormat event of a report.
If Not IsNull(DLookup("[ICD2]", "EntryICDs", "[EntryNum] = " & Me!
[PtAcct#])) Then
Me![Field192] = Replace(DLookup("[ICD2]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
End If
If Not IsNull(DLookup("[ICD3]", "EntryICDs", "[EntryNum] = " & Me!
[PtAcct#])) Then
Me![Field194] = Replace(DLookup("[ICD3]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
End If
If Not IsNull(DLookup("[ICD4]", "EntryICDs", "[EntryNum] = " & Me!
[PtAcct#])) Then
Me![Field196] = Replace(DLookup("[ICD4]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
End If
If I use the following code line alone:
Me![Field192] = Replace(DLookup("[ICD2]", "EntryICDs", "[EntryNum] =
" & Me![PtAcct#]), ".", " ")
I the Replace function yields an errrmsg if the DLookup function is null
Is there any way to use an 'if isnull' function or an IIf function to
accomplish the If---Then clauses that I have included, so that the coding is
neater?
TIA, Richard