Autonumber from 2 separate ranges?

kbrooks

Still learning
Local time
Today, 02:23
Joined
May 15, 2001
Messages
202
I am going to set up a database (for the 2nd time--first time was really messy and ugly) that will be used to register patients when our primary computer system is down. Doesn't happen a lot but when it does, it's for extended periods.

Patients need to be assigned an account number from 1 of 2 ranges, depending on whether they are an inpatient or an outpatient. In the previous db I set up, I had 2 separate forms to fill out...one for inpatients and one for outpatients. But I'm wondering if I can have ONE form, with a field where they answer either inpatient or outpatient, and that field would drive which range of numbers to autoassign a number from. Would I set up 2 tables, one for inpatient numbers and one for outpatient numbers?

TIA
 
If I read this problem correctly, the answer is either "you can't do this at all" or "you don't really want to do it this way."

If you have distinct tables that are structurally different depending on Inpatient/Outpatient status, and your patient number is an Autonumber, you will run the risk of overlapping numbers. Forcing a table to have a starting autonumber other than 1 is possible but Access is cantankerous at best about such things. Autonumbers tend to be reset too quickly. You would be unable to survive the "overlapping number" case.

If I read this correctly further between the lines, you are using this as a backup system to store data somewhere until another system comes back online. So my question is, how do you reconcile data between Access and the other system once it is back online? I think the resolution of number differences would have to be resolved at reconciliation time, not at initial data capture time.

Now, having rained on your parade, I'll suggest a way you can muddle through.

On your data entry form, make the Inpatient/Outpatient selector one of the first things you click. Capture everything you can that is common to both patient classes. Then when you need to do it, open one of two subforms depending on the state of that In/Out box. Collect only the stuff specific to patient type in that form.

In the subform, you might have to get kinky here. Make the common data have a single autonumber. Store the autonumber from the common data in the Inpatient table or the Outpatient table, whichever is applicable.

Since the relationship is sort of "backwards" with respect to your detail tables, your parent/child relationship must allow for "all Inpatients and any matching common parts", ditto for Outpatients. Now you have two tables, each of which is actually one-to-one with the common patient record. But because it is an either-or relationship, you cannot make it one-to-one. Technically, this is a SPARSE relationship. I.e. not fully populated.

How you reconcile this back to your master system is going to be tricky. I'll say this: You CANNOT establish a one-to-one relationship in which the common data portion refers to an autonumber from the type-specific portion. That would give you non-unique relationships.

Said another way, you cannot link parent-to-child in this context - but you could still link child-to-parent and just write your queries somewhat backwards.

On the other hand, if this is all an effort to retrofit something as a fallback to a larger system, you shouldn't have any trouble if you simply replicate the schema (on a smaller scale) of the target system for which you are providing the fallback. If their system can provide relational integrity, so can you (for the most part.) And if they CAN'T provide that integrity, then you shouldn't have to, either.
 
Will,

You could make your PK invisible to the user and on the
BeforeUpdate event of a checkbox OutPatient you could
use the DMax function like:

If Me.OutPatient = True Then
Me.PK = DMax("[PK]","[YourTable]", "[OutPatient] = True") +1
Else
Me.PK = DMax("[PK]","[YourTable]", "[OutPatient] = False") +1
End If

Obviously, you'll have to ensure that OutPatient is a
mandatory entry.


Wayne
 
Well we don't so much 'reconcile' data as we do input it into the main system once it's back up. Previously, we printed a report of all patients registered in this "downtime" database. We then went into our main patient accounting system and registered each patient there, making sure to assign them the same number they were given in the downtime db. (In the main system, we let the system assign the account number, but we do have the option to override it and manually assign it, which we do in this case.)

Our facility is driven by the account numbers each patient is assigned, and we have labels with this number that is attached to the patient chart, charge sheets, etc, etc. So it is crucial that the number they were given in the system (whether the downtime or main system) is the same number that is on these labels.

Thank you very much for your reply(s). I will have to print it out and read it again, as the majority of it went over my head the first time!! :)
 

Users who are viewing this thread

Back
Top Bottom