then, provided that is the only error, either the cnn connection is not using the 'CurrentProject.Connection' (ie. its connected to a different DB) or you have left the trailing space in the table name from my previous post (oops!!).
Irrespective of which database the ADO connection is connected to, the question is, as the error message says, does the table 'tblICReferralRecord' exist in the database that the code is written in, either as a physical or linked table?
Using ADO it does not matter if the tables are linked or not, provided the connection string (what connection string is currently being used?) provided it connects to the DB with the relevant tables. However, to use and domain functions (ie DMax() etc.) in the current Database (ie. the one in which the code is written) then the tables have to be in or linked to that Database. If this is not the case then you will recive the error message indicated.
Using the ADO connection you will need to return the value using a record set like
sql = "SELECT Max(PatientID) as MaxID FROM tblICReferralRecord"