Creating matching record

J

JCA

My database is essentially a set of data entry forms (for a clinical trial).
When a button at the bottom of each form is clicked, the next appropriate
form in the sequence will open. I have things set up so that the next form
opens at the appropriate record (i.e. the record with the Participant ID
value the same as the Participant ID value in the record just completed in
the previous form) if this record exists, but the fundamental thing which I
can’t work out how to do is to create this record (i.e. a new record with the
appropriate Participant ID) if it does not already exist.

Any help very gratefully received!
 
T

Tom van Stiphout

On Mon, 1 Feb 2010 06:17:01 -0800, JCA <[email protected]>
wrote:

In all cases I would open the next form with:
DoCmd.OpenForm "myNextFormName", OpenArgs:="ParticipantID=123"

Then in Form_Open you can write (off the top of my head):
dim lngParticipantID as long
lngParticipantID = Split(Me.OpenArgs, "=")(1)
with me.RecordsetClone
.FindFirst "ParticipantID=" & lngParticipantID
if .NoMatch then
RunCommand accmdRecordNew
Me.ParticipantID = lngParticipantID
else
Me.bookmark = .Bookmark
end if
end with

-Tom.
Microsoft Access MVP
 

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