Special elections were held in Maryland's 5th congressional district on January 1, 1823 to fill vacancies in the 17th and 18th Congresses caused by the resignation of Samuel Smith (DR) after being elected to the Senate. Smith had been re-elected to the House in October. His resignation therefore created vacancies both in the remainder of the 17th Congress and in the 18th Congress.
Election to the 17th Congress
McKim took his seat on January 8, 1823
References
Maryland's 5th congressional district special elections, 1823 Wikipedia(Text) CC BY-SA