I am trying to create a function that can be called from several forms to validate an entry in a table.
What I would like to do is pass a user-input value to the function, have the function test to see if a record with the passed value exists in a specific table (in the primary key field), and return a value of true if the record exists, false if it doesn't.
For some reason, I can't seem to get this to work with either FindRecord, FindFirst, Seek, or DLookUp functions but I'm sure I'm doing something wrong. For what it's worth, the name of the table to be searched has the same name as the database and this seems to be causing problems, even when I stick a Tables! in front of the table name.
The function will be used when the user clicks on an "add new record" button to test whether the primary key already exists before the user goes through the entire form (since Access only appears to test whether the primary key is duplicated just before the data is written into the new record). If there are better ways to accomplish this, that would be helpful too.
Any thoughts? Thanks in advance.
What I would like to do is pass a user-input value to the function, have the function test to see if a record with the passed value exists in a specific table (in the primary key field), and return a value of true if the record exists, false if it doesn't.
For some reason, I can't seem to get this to work with either FindRecord, FindFirst, Seek, or DLookUp functions but I'm sure I'm doing something wrong. For what it's worth, the name of the table to be searched has the same name as the database and this seems to be causing problems, even when I stick a Tables! in front of the table name.
The function will be used when the user clicks on an "add new record" button to test whether the primary key already exists before the user goes through the entire form (since Access only appears to test whether the primary key is duplicated just before the data is written into the new record). If there are better ways to accomplish this, that would be helpful too.
Any thoughts? Thanks in advance.