One thing you can do is to enforce uniqueness on the table.
In the indexes dialog you can create an index that incorporates the three fields, asserting that it must be unique. Then you will be unable to save a record that would violate that. This will behave like the table you say you do not have, one with a single column to check.
Running a query through runSQL is meaningless in the undertaking here; it is for running queries that modify the data. You need to open a recordset with these criteria, and examine the recordset's properties.
When you open the recordset (letâs say it is called ârâ), if both r.EOF and r.BOF are true, then no records were returned matching your criteria. You can go ahead and close that recordset, then save the contents of the form.
But if that recordset has a record in it (r.EOF is False), close the recordset, explain what the deal is in a MsgBox, followed by setting Cancel = True in the BeforeUpdate event.
Cancel is a variable that it initialized by Access, then passed into the BeforeUpdate event by reference. Because it is passed in by reference, if you change it, its value in the calling routine (the part of Access that called the BeforeUpdate routine) will be changed when Access get back there. When the BeforeUpdate event is through running, Access checks the value of that variable. If it has been changed to True, Then Access cancels the update.
If I were you, for ease of reading, I would change what you have to:
Code:
strSql = "SELECT Journal, Volume, Page " & _
"FROM tbl_Papers " & _
"WHERE Journal = " & Form!Journal.Value & " AND " & _
" Volume = '" & Form!Volume.Value & "' AND " & _
" Page = '" & Form!Page.Value & "'"
In a 1-table query there is no potential for ambiguous field references, so fully-qualifying every field reference is unnecessary.
All of those parentheses (while Access always adds them in the query builder) do nothing to make the query run better, and they are really hard on the brain.
Queries ignore white-space, so you can add spaces to line things up for clarity. (Be careful not to add spaces that will wind up inside literal strings though!)