Using Access 2007
My table (TblPtDemographi cs) contains a primary key of PtID, which is a numeric field.
Linked to this table is TblKneeSurgeryI nfo, which contains a primary of SxKneeID, which is a text field. It also has a field SxKneeSide, which designates "Right" or "Left."
The format of SxKneeID should be as follows:
R111111S1
1. Where "R" indicates that the right knee was operated on (as found in SxKneeSide)
2. "111111" is the value in PtID
3. "S" is a constant indicating surgery
4. "1" indicates the first surgery the person has had on the right knee.
My main question is: How can I set up the code that would automatically generate a string to put in the SxKneeID field? I need to trim the "Right" and "Left" values down to the first letter and have access sort of autonumber the last portion of the string (for instance, if "R111111S1" already exists, use "R111111S2" when creating a new record).
I know how to get the PtID field and "S" into the string, but as for the other part--- I'm not sure how to set this up using VBA. Any help would be appreciated!
My table (TblPtDemographi cs) contains a primary key of PtID, which is a numeric field.
Linked to this table is TblKneeSurgeryI nfo, which contains a primary of SxKneeID, which is a text field. It also has a field SxKneeSide, which designates "Right" or "Left."
The format of SxKneeID should be as follows:
R111111S1
1. Where "R" indicates that the right knee was operated on (as found in SxKneeSide)
2. "111111" is the value in PtID
3. "S" is a constant indicating surgery
4. "1" indicates the first surgery the person has had on the right knee.
My main question is: How can I set up the code that would automatically generate a string to put in the SxKneeID field? I need to trim the "Right" and "Left" values down to the first letter and have access sort of autonumber the last portion of the string (for instance, if "R111111S1" already exists, use "R111111S2" when creating a new record).
I know how to get the PtID field and "S" into the string, but as for the other part--- I'm not sure how to set this up using VBA. Any help would be appreciated!
Comment