G
Guest
I'm trying to build the complete address from individual fields like
'Address1', 'Address2' etc. from tblAddresses. The idea behind the +
concatenation is to avoid the extra commas for null fields in the Address
Block.
The following code gives me an "Invalid Use of Null" message. Can someone
please point out where I'm doing wrong ?
Public Function FullAddress(strID As String, strAddressType As String) As
String
On Error GoTo ErrHandle
Dim AddBlock As String
Dim strWhere As String
strWhere = "[ID] = '" & strID & "'"
strWhere = strWhere & " AND [AddressType] = '" & strAddressType & "'"
AddBlock = DLookup("Address1", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address2", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address3", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address4", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address5", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address6", "tblAddresses", strWhere)
FullAddress = AddBlock
ExitHandle:
Exit Function
ErrHandle:
LogError "FullAddress" & modName, err, Error
Resume ExitHandle
End Function
'Address1', 'Address2' etc. from tblAddresses. The idea behind the +
concatenation is to avoid the extra commas for null fields in the Address
Block.
The following code gives me an "Invalid Use of Null" message. Can someone
please point out where I'm doing wrong ?
Public Function FullAddress(strID As String, strAddressType As String) As
String
On Error GoTo ErrHandle
Dim AddBlock As String
Dim strWhere As String
strWhere = "[ID] = '" & strID & "'"
strWhere = strWhere & " AND [AddressType] = '" & strAddressType & "'"
AddBlock = DLookup("Address1", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address2", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address3", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address4", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address5", "tblAddresses", strWhere)
AddBlock = AddBlock + ", " + DLookup("Address6", "tblAddresses", strWhere)
FullAddress = AddBlock
ExitHandle:
Exit Function
ErrHandle:
LogError "FullAddress" & modName, err, Error
Resume ExitHandle
End Function