I think it is because you need two spaces in your query. On the where and order by lines there was no space.
strSQL="SELECT * FROM MASTER M,Reference_company R"
strSQL=strSQL & " WHERE M.CompanyRefKey = R.ReferenceKey"
strSQL=strSQL & " ORDER BY "& order_string
http://mynameissteve.com