Automatic value increment upon creating new record in subform

E

etter34

Hello,

First, I know automatic value increment has been talked about a lot,
but I can't seem to get this particular issue resolved. Basically what
I have are "Case numbers" (automatically assigned) and then "patient
id's" within that case number. So if we want to enter in 3 patients
that came in at the same time, they'd all be under the same case
number.

I've got a form with the "case number" that is automatically
incremented when a case comes in, and then a subform with the "patient
id" and patient info that needs to increase when people click new
record. The "Patient ID" field should match the record number in the
navigation bar. Currently, whenever someone clicks new record they
have to manually change the "patient id" since it does not
automatically increment.

I hope this makes sense! I want "patient id" to increase automatically
for each "case number" in the short!

Any direction to examples, etc? Thanks so much!
 
K

kingston via AccessMonster.com

Your description of what you want to happen would lead to duplicate Patient
IDs:

Case 1
Patient 1
Patient 2
Patient 3

Case 2
Patient 1
Patient 2

If this is the case, Patient ID is not really an ID in the sense of a data
table key (it can be part of a composite ID but I'm not sure if that's what
you're trying to do). Do you have a real ID for patient information? If so,
good, and we'll call the number you want PatientCount instead. You can get
the current PatientCount using something like: DCount("*","CasePatientTable",
"[CaseID]=12"). Naturally, you need to substitute the real table name and
field name. If CaseID is not numeric, you'll need to add single quotes
around the value. If you place this in a form, you can replace the criteria
with something like: "[CaseID]=" & Me.CaseID. Thus, the next PatientCount
would simply be DCount(...)+1.

In summary, CaseID will be an autonumber, PatientID should be an autonumber
(hopefully), and PatientCount will be calculated. There are potential
problems and inefficiencies with adding a PatientCount field (what if a
patient is deleted from a case - do you reassign all the numbers?). So, it
would be much better if you could work with two true IDs (Case and Patient)
that are automatically assigned.
 

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