The issue here is that the function GetColumnRef is using simple DLookup for finding the column reference number in the table dbo_tblColumns.
To fix this issue you need to do two things.
1) Fix GetColumnRef function DLookup statement:
Private Function GetColumnRef(ByVal strFieldName, ByVal...