
Originally Posted by
June7
Okay, that is good to know. Apparently I did not pick one of the problem records. Cause of issue is the apostrophe in the hotel names. Apostrophes and quote marks within SQL are an issue because of their special purposes. The search criteria in the SearchForRecord method is like the WHERE clause of an SQL statement and follows the same rules. Apostrophe and quote marks must be doubled within the string so as to be recognized as text and not special character (this is referred to as 'escaping' special characters). I don't use macros so I converted to VBA.
DoCmd.SearchForRecord , "", acFirst, "[HotelName]='" & Replace(Screen.ActiveControl, "'", "''") & "'"
There would not be an issue if you did search on HotelID. If you don't save the HotelID as foreign key then it serves no purpose to designate it as primary key. Since you save HotelName as foreign key, it should be designated primary key.