SQL Access

G

Grant Nosbush

Hopefully someone can be of some help with the following question. I am
putting together a database that tracks patients at different centers
for a research project.

I have created a form to enter background information for each patient.
Currently, when this form loads, it opens another sub-form asking for
the center id and patient id. These two variables are passed back to
the background form.

What I want to happen is when the user clicks okay on the sub-form, I
want Access to check the background database and see if there already is
a record with this center id and patient id. If so, the background form
would load it. If the record does not exist, I want to have Access
create a new record by pulling in the center id and patient id and then
load the background form with this newly created record.

Hopefully this is real simple and I'm just missing something here. I've
been working all day trying to put this together so I'm kind of tired.

My assumption is this code would all go in the sub for the okay button
on click. Can someone suggest how to go about this? Thanks
 
V

Van T. Dinh

You can check whether a Record exists or not using the DCount() or DLookUp()
function or Recordset. Since you already have the relevant Recordset in the
first Form (background Form in your terminology), it may be convenient to
use the Recordset of this Form.

Check Access VB Help on the FindFirst Method and the BookMark Property of
the Form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top